This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Christopher.King
Recipients Christopher.King, benjamin.peterson, bogklug, r.david.murray
Date 2013-02-26.19:23:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1361906581.44.0.262017644838.issue7423@psf.upfronthosting.co.za>
In-reply-to
Content
This is a crazy and unexpected behavior.  (Moreover, the fact that Python has dynamic scope *only if you forget to initialize a variable* is even more crazy and unexpected.)  To provide unsurprising behavior (i.e. behavior compatible with that of a list comprehension) the generator above should "unwrap" (i.e. reduce) to:

def g1(x):
    for y in 'c':
        yield x+y
l = []
for x in 'ab':
    l.append(g1(x))
print l
print map(list, l)

i.e. the variables referenced by, but not initialized by, the innermost generator should add extra parameters to the generated generator function.
History
Date User Action Args
2013-02-26 19:23:01Christopher.Kingsetrecipients: + Christopher.King, benjamin.peterson, r.david.murray, bogklug
2013-02-26 19:23:01Christopher.Kingsetmessageid: <1361906581.44.0.262017644838.issue7423@psf.upfronthosting.co.za>
2013-02-26 19:23:01Christopher.Kinglinkissue7423 messages
2013-02-26 19:23:00Christopher.Kingcreate