W dniu 11.10.2012 01:29, Jan Kaliszewski napisaĆ(a):
The goal described by the OP could be reached with a wrapper generator -- something like this: [snip]
PS. A more convenient version (you don't need to repeat yourself): [snip].
PS2. Sorry for flooding, obviously it can be simpler: import collections def genfrom(iter_factory, *args): final_value = None def catching(iterable): nonlocal final_value final_value = yield from iterable args = [catching(arg.iterable) if isinstance(arg, genfrom.this) else arg for arg in args] yield from iter_factory(*args) return final_value genfrom.this = collections.namedtuple('propagate_from_this', 'iterable') Cheers. *j