yield_all needed in Python
Skip Montanaro
skip at pobox.com
Tue Mar 1 13:42:51 EST 2005
Doug> def foogen(arg1):
Doug> def foogen1(arg2):
Doug> # Some code here
Doug> # Some code here
Doug> yield_all foogen1(arg3)
Doug> # Some code here
Doug> yield_all foogen1(arg4)
Doug> # Some code here
Doug> yield_all foogen1(arg5)
Doug> # Some code here
Doug> yield_all foogen1(arg6)
If this idea advances I'd rather see extra syntactic sugar introduced to
complement the current yield statement instead of adding a new keyword.
It's a bit clumsy to come up with something that will work syntactically
since the next token following the yield keyword can be any identifier.
You'd thus need another keyword there. Something like:
def foogen(arg1):
def foogen1(arg2):
# Some code here
# Some code here
yield from foogen1(arg3)
# Some code here
yield from foogen1(arg4)
# Some code here
yield from foogen1(arg5)
# Some code here
yield from foogen1(arg6)
It would be nicer if that was
yield all from <something>
but since "all" is a valid identifier that might break existing code, though
maybe the presence of the following "from" can be used to distinguish
these two cases:
yield <expr>
yield all from <expr>
Skip
More information about the Python-list
mailing list