This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author py.user
Recipients docs@python, eric.smith, ezio.melotti, py.user, rhettinger
Date 2013-08-08.17:19:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1375982395.16.0.456474414957.issue18313@psf.upfronthosting.co.za>
In-reply-to
Content
> This would require you to provide at least two elements
I see
how about "def repeatfunc(func, *args, times=None):" ?


>>> from itertools import starmap, repeat
>>> 
>>> def repeatfunc(func, *args, times=None):
...     """Repeat calls to func with specified arguments.
... 
...     Example:  repeatfunc(random.random)
...     """
...     if times is None:
...         return starmap(func, repeat(args))
...     return starmap(func, repeat(args, times))
... 
>>> def f(*args):
...     print(args)
... 
>>> r = repeatfunc(f, 1, 2)
>>> next(r)
(1, 2)
>>> next(r)
(1, 2)
>>> next(r)
(1, 2)
>>> r = repeatfunc(f, 1, 2, times=1)
>>> next(r)
(1, 2)
>>> next(r)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration
>>>
History
Date User Action Args
2013-08-08 17:19:55py.usersetrecipients: + py.user, rhettinger, eric.smith, ezio.melotti, docs@python
2013-08-08 17:19:55py.usersetmessageid: <1375982395.16.0.456474414957.issue18313@psf.upfronthosting.co.za>
2013-08-08 17:19:55py.userlinkissue18313 messages
2013-08-08 17:19:55py.usercreate