[Python-bugs-list] [ python-Bugs-827209 ] List comprehensions
leaking control variable name deprecated
SourceForge.net
noreply at sourceforge.net
Tue Oct 21 10:26:19 EDT 2003
Bugs item #827209, was opened at 2003-10-21 01:41
Message generated for change (Comment added) made by sjoerd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=827209&group_id=5470
Category: Documentation
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Delaney (tcdelaney)
Assigned to: Nobody/Anonymous (nobody)
Summary: List comprehensions leaking control variable name deprecated
Initial Comment:
According to the email thread starting:
http://mail.python.org/pipermail/python-dev/2003-
October/039081.html
the control variable name in a list comprehension should
not be leaked and any use of such a leaked name is
deprecated.
----------------------------------------------------------------------
>Comment By: Sjoerd Mullender (sjoerd)
Date: 2003-10-21 16:26
Message:
Logged In: YES
user_id=43607
Actually, this is not different from
$ python
Python 2.4a0 (#2, Oct 14 2003, 11:28:48)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> for x in []:
... pass
...
>>> print x
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'x' is not defined
>>>
where x is also undefined after iteraring through an empty list.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2003-10-21 15:52
Message:
Logged In: YES
user_id=44345
A good point raised by Michael Hudson is that
foo = [x for x in R]
print x
will fail if R is empty (and x wasn't previously defined).
All the more reason to deprecate its usage and
suppress the leaking variable.
----------------------------------------------------------------------
Comment By: Terry J. Reedy (tjreedy)
Date: 2003-10-21 02:04
Message:
Logged In: YES
user_id=593130
Ref Man 5.2.4 List displays: suggested addition at end.
Using leaked 'for <exp_list>' control variables outside the list
display is deprecated and will not work when the bug is fixed.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=827209&group_id=5470
More information about the Python-bugs-list
mailing list