Skip to content

Commit

Permalink
Add clear() method to dictionary objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Mar 21, 1997
1 parent 35d48e9 commit 7ff5d88
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,20 @@ mapping_has_key(mp, args)
return newintobject(ok);
}

static object *
mapping_clear(mp, args)
register mappingobject *mp;
object *args;
{
if (!getnoarg(args))
return NULL;
mappingclear((object *)mp);
INCREF(None);
return None;
}

static struct methodlist mapp_methods[] = {
{"clear", (method)mapping_clear},
{"has_key", (method)mapping_has_key},
{"items", (method)mapping_items},
{"keys", (method)mapping_keys},
Expand Down
13 changes: 13 additions & 0 deletions Objects/mappingobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,20 @@ mapping_has_key(mp, args)
return newintobject(ok);
}

static object *
mapping_clear(mp, args)
register mappingobject *mp;
object *args;
{
if (!getnoarg(args))
return NULL;
mappingclear((object *)mp);
INCREF(None);
return None;
}

static struct methodlist mapp_methods[] = {
{"clear", (method)mapping_clear},
{"has_key", (method)mapping_has_key},
{"items", (method)mapping_items},
{"keys", (method)mapping_keys},
Expand Down

0 comments on commit 7ff5d88

Please sign in to comment.