Deprecated: list comp leak use

John Roth newsgroups at jhrothjr.com
Tue Oct 21 07:32:33 EDT 2003


"Terry Reedy" <tjreedy at udel.edu> wrote in message
news:c8ydnYL_P9UILgmiRVn-jw at comcast.com...
> Announcement/Warning
>
> In the current implementation of list comprehensions, for-part control
> variables leak to the surrounding context.  Example:
> >>> [i for i in [1,2]]
> [1, 2]
> >>> print i
> 2
> The name i was bound within the list comprehension.  The Reference
> Manual currently says nothing about this behavior.

However, the tutorial for 2.2.3 not only describes it, but it
gives an example of how it can be used.

John Roth
>
> Terry J. Reedy
>
>






More information about the Python-list mailing list