diff options
author | Raymond Hettinger <python@rcn.com> | 2009-02-19 02:44:01 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-02-19 02:44:01 (GMT) |
commit | f4bb7f21000d28ef7aed350d2ce9113a4ae0817d (patch) | |
tree | efceb1c8013b5315e63ce6f22fd7bb641f388bc1 /Modules/itertoolsmodule.c | |
parent | 15a4950da1a80b334ee4985c62e66a1e1071a951 (diff) | |
download | cpython-f4bb7f21000d28ef7aed350d2ce9113a4ae0817d.zip cpython-f4bb7f21000d28ef7aed350d2ce9113a4ae0817d.tar.gz cpython-f4bb7f21000d28ef7aed350d2ce9113a4ae0817d.tar.bz2 |
Add keyword arg support to itertools.repeat().
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index e2ca9c7..48dffe5 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -3106,11 +3106,10 @@ repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds) repeatobject *ro; PyObject *element; Py_ssize_t cnt = -1; - - if (type == &repeat_type && !_PyArg_NoKeywords("repeat()", kwds)) - return NULL; - - if (!PyArg_ParseTuple(args, "O|n:repeat", &element, &cnt)) + static char *kwargs[] = {"object", "times", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:repeat", kwargs, + &element, &cnt)) return NULL; if (PyTuple_Size(args) == 2 && cnt < 0) @@ -3178,8 +3177,8 @@ static PyMethodDef repeat_methods[] = { }; PyDoc_STRVAR(repeat_doc, -"repeat(element [,times]) -> create an iterator which returns the element\n\ -for the specified number of times. If not specified, returns the element\n\ +"repeat(object [,times]) -> create an iterator which returns the object\n\ +for the specified number of times. If not specified, returns the object\n\ endlessly."); static PyTypeObject repeat_type = { |