R. David Murray <rdmur...@bitdance.com> added the comment: 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'] ---------- nosy: +r.david.murray _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7423> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com