yield_all needed in Python
Mike C. Fletcher
mcfletch at rogers.com
Tue Mar 1 14:48:02 EST 2005
Skip Montanaro wrote:
...
>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:
>
>
I'd agree on *not* introducing a new keyword. I run into this issue
every once in a while, but new keywords for minor syntactic sugar seems
a bit much.
> # Some code here
> yield from foogen1(arg3)
>
>
...
>It would be nicer if that was
>
> yield all from <something>
>
>
I don't really like the need to look past that (potentially long)
expression to see the effect of the operation. I don't mind the yield
from syntax, it nicely encapsulates the learning of "generators" so that
when you see yield up front you know something generatish is going on.
I'd be fine with:
for yield on foogen1(arg3)
or
for yield from foogen1(arg3)
which goes more toward the idea of being syntactic sugar for a for loop
that yields each value that is produced. Of course, what happens with:
[ for yield from foogen1(arg3) ]
would then have to be defined... that might make it too complex an
change. Oh well.
Have fun all,
Mike
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
PyCon is coming...
More information about the Python-list
mailing list