yield_all needed in Python

Skip Montanaro skip at pobox.com
Wed Mar 2 15:32:06 EST 2005


    Jeremy> At first I liked this, but the reason that is a syntax error is
    Jeremy> that it is "supposed" to be

    Jeremy> def f():
    Jeremy>     yield (x for x in gen1(arg))

    Jeremy> which today on 2.4 returns a generator instance which will in
    Jeremy> turn yield one generator instance from the genexp, and I am
    Jeremy> quite uncomfortable with the difference between the proposed
    Jeremy> behaviors with and without the parens.

    Jeremy> Which sucks, because at first I really liked it :-)

    Jeremy> We still would need some syntax to say "yield this 'in place'
    Jeremy> rather than as an object".

def f():
    yield from (x for x in gen1(arg))

Skip



More information about the Python-list mailing list