diff Modules/itertoolsmodule.c @ 51624:2a263d66d659

Add keyword argument support to itertools.count().
author Raymond Hettinger <python@rcn.com>
date Sat, 14 Feb 2009 04:21:49 +0000
parents cb8190a1bfab
children 003e00797e91
line wrap: on
line diff
--- a/Modules/itertoolsmodule.c	Fri Feb 13 23:48:11 2009 +0000
+++ b/Modules/itertoolsmodule.c	Sat Feb 14 04:21:49 2009 +0000
@@ -2916,11 +2916,10 @@
 	Py_ssize_t cnt = 0;
 	PyObject *long_cnt = NULL;
 	PyObject *long_step = NULL;
-
-	if (type == &count_type && !_PyArg_NoKeywords("count()", kwds))
-		return NULL;
-
-	if (!PyArg_UnpackTuple(args, "count", 0, 2, &long_cnt, &long_step))
+	static char *kwlist[] = {"start", "step", 0};
+
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:count",
+			kwlist, &long_cnt, &long_step))
 		return NULL;
 
 	if (long_cnt != NULL && !PyNumber_Check(long_cnt) ||
@@ -3027,10 +3026,10 @@
 }
 
 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\