summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-03-21 21:55:12 (GMT)
committerGuido van Rossum <guido@python.org>1997-03-21 21:55:12 (GMT)
commitfb8f1cadb279d34860d31f67813e4b405411d3da (patch)
tree6f6b4c280f9f187d528a7ead9850a56cf00e9c8c /Objects
parent3ee6b195bbe8272b5901f3f97c0966ddd4bb72fa (diff)
downloadcpython-fb8f1cadb279d34860d31f67813e4b405411d3da.zip
cpython-fb8f1cadb279d34860d31f67813e4b405411d3da.tar.gz
cpython-fb8f1cadb279d34860d31f67813e4b405411d3da.tar.bz2
Add clear() method to dictionary objects.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c13
-rw-r--r--Objects/mappingobject.c13
2 files changed, 26 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 8f3d3a6..51f0018 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -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},
diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c
index 8f3d3a6..51f0018 100644
--- a/Objects/mappingobject.c
+++ b/Objects/mappingobject.c
@@ -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},