This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kousu
Recipients kousu
Date 2008-04-01.19:19:08
SpamBayes Score 0.048838098
Marked as misclassified No
Message-id <1207077549.89.0.118557412226.issue2529@psf.upfronthosting.co.za>
In-reply-to
Content
I think I've found a bug in python's list comprehension parser. Observe:

>>> [e for i in j in ['a','b','c']]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'j' is not defined

Now, according to the grammar at http://docs.python.org/ref/lists.html,
a list comprehension is (condensed for clarity):
list_comprehension 	::= 	expression list_for
list_for 	::= 	"for" target_list "in" old_expression_list [list_for]

So a list comprehension should always be 
[.... for ... in .... for ... in ... for ... in ...]
(that is, alternating 'for's and 'in's) but here I have a test case that
python happily tries to run that looks like
[... for ... in ... in ....]
History
Date User Action Args
2008-04-01 19:19:10koususetspambayes_score: 0.0488381 -> 0.048838098
recipients: + kousu
2008-04-01 19:19:09koususetspambayes_score: 0.0488381 -> 0.0488381
messageid: <1207077549.89.0.118557412226.issue2529@psf.upfronthosting.co.za>
2008-04-01 19:19:09kousulinkissue2529 messages
2008-04-01 19:19:08kousucreate