py.user added the comment:
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
---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18313> _______________________________________