diff options
author | Raymond Hettinger <python@rcn.com> | 2009-02-19 02:38:25 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-02-19 02:38:25 (GMT) |
commit | 182edaefb515ece87d225494d79ccf7dd35d1ec1 (patch) | |
tree | bac7eca23ebbfec6b076ef213cc0c4afbb54b45b /Modules | |
parent | 2e2909f58482f5c780c58549f04f7cf325b94e02 (diff) | |
download | cpython-182edaefb515ece87d225494d79ccf7dd35d1ec1.zip cpython-182edaefb515ece87d225494d79ccf7dd35d1ec1.tar.gz cpython-182edaefb515ece87d225494d79ccf7dd35d1ec1.tar.bz2 |
Add keyword arg support to itertools.repeat().
Diffstat (limited to 'Modules')
-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 3c6d618..4aa02b6 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -3617,11 +3617,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) @@ -3699,8 +3698,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 = { |