[Tutor] list comprehensions isolate variables but for loops don't - is there a special usage?
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Wed Jun 5 09:47:34 CEST 2013
Alan Gauld <alan.gauld <at> btinternet.com> writes:
>
> To be honest I didn't realize that comprehensions (and I assume
> generators in general) created their own local namespace.
This is true only for Python 3. In Python 2.x comprehensions and for loops
behave the same way. See this post on python-ideas:
http://article.gmane.org/gmane.comp.python.ideas/19151
Best,
Wolfgang
More information about the Tutor
mailing list