Bug in list comprehensions in Pyhton 2.1.1?
tim.one at home.com
Sun Nov 11 08:35:37 CET 2001
> The code below can be copied and run as is. Hopefully it documents
> clearly enough what to me seems to be a bug in list comprehensions:
> the global namespace is polluted with a local variable which was only
> used as the dummy running index of the list comprehension.
> def flatten_bug(seq):
> # a *global* variable x is left over after calling this function,
> # with the value of the last element in the return list
> return [x for subseq in seq for x in subseq]
This was a bug, and was fixed last month (for 2.2; perhaps also for 2.1.2).
More information about the Python-list