On 2006-10-04, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Georg Brandl wrote: > >>> But that can only work if you are the author of f. Take the >>> following code: >>> >>> def myrepeat(obj, times = xxx): >>> return itertools.repeat(obj, times) >>> >>> What value do I have to substitue for xxx, so that myrepeat >>> will have the exact same function as itertools.repeat? >> >> There's no possible value. You'll have to write this like >> >> def myrepeat(obj, times=None): >> if times is None: >> return itertools.repeat(obj) >> else: >> return itertools.repeat(obj, times) > > or: > > def myrepeat(*args): > return itertools.repeat(*args)
Yes that works but I have the impression that this solution becomes complicated very fast once you want to do extra processing in the function body. Take the following def myrepeat(obj, times = xxx)" newobj = Process(obj) return itertools.repeat(obj, times) I think it would become something like: def myrepeat(*args): obj = args[0] tail = args[1:] newobj = Process(obj) newargs = (newobj,) + tail return itertools.repeat(*newargs) -- http://mail.python.org/mailman/listinfo/python-list