[docs] [issue18313] In itertools recipes repeatfunc() defines a non-keyword argument as keyword

Raymond Hettinger report at bugs.python.org
Mon Sep 9 09:34:57 CEST 2013

Raymond Hettinger added the comment:

All of the proposed variants have their own issues.  

For example, the keyword-argument variant behaves badly if the user leaves off the keyword:

  >>> list(repeatfunc(ord, 'A', times=3))
  [65, 65, 65]
  >>> list(repeatfunc(ord, 'A', 3))
  Traceback (most recent call last):
    File "<pyshell#12>", line 1, in <module>
      list(repeatfunc(ord, 'A', 3))
  TypeError: ord() takes exactly one argument (2 given)

I prefer to leave the recipe as is.  The primary purpose of the recipe is to illustrate how starmap() and repeat() can be used together.  Will that knowledge, a user can easily cobble together in-line code for either the finite version or the infinite iterable version.

priority: normal -> low
resolution:  -> rejected
status: open -> closed

Python tracker <report at bugs.python.org>

More information about the docs mailing list