summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-02-14 00:25:51 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-02-14 00:25:51 (GMT)
commita4038038c69c72f96f1c7d435d50818c46892591 (patch)
treed766cc7067bdf647a2ee974bc4e20d77bd245ddc /Modules
parent544c3e19e6b6c8162c45a22594c6b929fd14f427 (diff)
downloadcpython-a4038038c69c72f96f1c7d435d50818c46892591.zip
cpython-a4038038c69c72f96f1c7d435d50818c46892591.tar.gz
cpython-a4038038c69c72f96f1c7d435d50818c46892591.tar.bz2
Add keyword argument support to itertools.count().
Diffstat (limited to 'Modules')
-rw-r--r--Modules/itertoolsmodule.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index c8e6053..8a40427 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -3233,11 +3233,10 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_ssize_t cnt = 0;
PyObject *long_cnt = NULL;
PyObject *long_step = NULL;
+ static char *kwlist[] = {"start", "step", 0};
- if (type == &count_type && !_PyArg_NoKeywords("count()", kwds))
- return NULL;
-
- if (!PyArg_UnpackTuple(args, "count", 0, 2, &long_cnt, &long_step))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:count",
+ kwlist, &long_cnt, &long_step))
return NULL;
if (long_cnt != NULL && !PyNumber_Check(long_cnt) ||
@@ -3353,10 +3352,10 @@ count_repr(countobject *lz)
}
PyDoc_STRVAR(count_doc,
- "count([firstval[, step]]) --> count object\n\
+ "count([start[, step]]) --> count object\n\
\n\
Return a count object whose .next() method returns consecutive\n\
-integers starting from zero or, if specified, from firstval.\n\
+integers starting from zero or, if specified, from start.\n\
If step is specified, counts by that interval. Equivalent to:\n\n\
def count(firstval=0, step=1):\n\
x = firstval\n\