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 r.david.murray
Recipients benjamin.peterson, bogklug, r.david.murray
Date 2009-12-02.02:04:00
SpamBayes Score 0.0013734536
Marked as misclassified No
Message-id <1259719442.35.0.719048596446.issue7423@psf.upfronthosting.co.za>
In-reply-to
Content
I'd already written then when Benjamin posted his answer, but rather
than waste having written it I'm going to post it anyway :)

You must remember that the purpose of a generator is to evaluate lazily.
 Your expression involving the generator would unwrap this way:

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

If you run this you will note that 'l' is a pair of generator instances.
 These are not run until the 'map' is executed. By that point the for
loop has completed, and x has its final value, 'b'.  g1 is evaluated
twice, and both times x is 'b', so you get ['bc', 'bc']
History
Date User Action Args
2009-12-02 02:04:03r.david.murraysetrecipients: + r.david.murray, benjamin.peterson, bogklug
2009-12-02 02:04:02r.david.murraysetmessageid: <1259719442.35.0.719048596446.issue7423@psf.upfronthosting.co.za>
2009-12-02 02:04:00r.david.murraylinkissue7423 messages
2009-12-02 02:04:00r.david.murraycreate