mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Add clear() method to dictionary objects.
This commit is contained in:
parent
3ee6b195bb
commit
fb8f1cadb2
2 changed files with 26 additions and 0 deletions
|
@ -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},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue