strange list comprehension on generator

"Martin v. Löwis" martin at
Wed Aug 29 16:40:49 CEST 2007

> #this does not return the way I would expect. why?

You yield the very same list object all the times. So
when you make a later change, all earlier results will
get changed, too (since they are the same object).
Of course, it won't affect the terminal output, so you
don't see that the older values changed in the example
that you think works as expected.


More information about the Python-list mailing list