summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-03-25 17:43:22 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2002-03-25 17:43:22 (GMT)
commite990c79fa843309f619819d6aa4bc34353282545 (patch)
treedcf8ea24e942682eabddb832683566d913168b29 /Objects
parent3787c9d94ce2bb913e92ab7aa7d74997aa5a0228 (diff)
downloadcpython-e990c79fa843309f619819d6aa4bc34353282545.zip
cpython-e990c79fa843309f619819d6aa4bc34353282545.tar.gz
cpython-e990c79fa843309f619819d6aa4bc34353282545.tar.bz2
Add missing methods iterkeys, itervalues and iteritems to
dict-proxy objects. Add real docstrings to all methods.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/descrobject.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index e7aa4ec..924c0b2 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -644,18 +644,38 @@ proxy_items(proxyobject *pp)
}
static PyObject *
+proxy_iterkeys(proxyobject *pp)
+{
+ return PyObject_CallMethod(pp->dict, "iterkeys", NULL);
+}
+
+static PyObject *
+proxy_itervalues(proxyobject *pp)
+{
+ return PyObject_CallMethod(pp->dict, "itervalues", NULL);
+}
+
+static PyObject *
+proxy_iteritems(proxyobject *pp)
+{
+ return PyObject_CallMethod(pp->dict, "iteritems", NULL);
+}
+static PyObject *
proxy_copy(proxyobject *pp)
{
return PyObject_CallMethod(pp->dict, "copy", NULL);
}
static PyMethodDef proxy_methods[] = {
- {"has_key", (PyCFunction)proxy_has_key, METH_O, "XXX"},
- {"get", (PyCFunction)proxy_get, METH_VARARGS, "XXX"},
- {"keys", (PyCFunction)proxy_keys, METH_NOARGS, "XXX"},
- {"values", (PyCFunction)proxy_values, METH_NOARGS, "XXX"},
- {"items", (PyCFunction)proxy_items, METH_NOARGS, "XXX"},
- {"copy", (PyCFunction)proxy_copy, METH_NOARGS, "XXX"},
+ {"has_key", (PyCFunction)proxy_has_key, METH_O, "D.has_key(k) -> 1 if D has a key k, else 0"},
+ {"get", (PyCFunction)proxy_get, METH_VARARGS, "D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None."},
+ {"keys", (PyCFunction)proxy_keys, METH_NOARGS, "D.keys() -> list of D's keys"},
+ {"values", (PyCFunction)proxy_values, METH_NOARGS, "D.values() -> list of D's values"},
+ {"items", (PyCFunction)proxy_items, METH_NOARGS, "D.items() -> list of D's (key, value) pairs, as 2-tuples"},
+ {"iterkeys", (PyCFunction)proxy_iterkeys, METH_NOARGS, "D.iterkeys() -> an iterator over the keys of D"},
+ {"itervalues",(PyCFunction)proxy_itervalues, METH_NOARGS, "D.itervalues() -> an iterator over the values of D"},
+ {"iteritems", (PyCFunction)proxy_iteritems, METH_NOARGS, "D.iteritems() -> an iterator over the (key, value) items of D"},
+ {"copy", (PyCFunction)proxy_copy, METH_NOARGS, "D.copy() -> a shallow copy of D"},
{0}
};