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 lehmannro
Recipients kousu, lehmannro
Date 2008-04-01.20:04:40
SpamBayes Score 0.5859124
Marked as misclassified No
Message-id <1207080284.05.0.876108272174.issue2529@psf.upfronthosting.co.za>
In-reply-to
Content
Your example is parsed as [e for i in (j in ['a','b','c'])] and since
`j` is not defined, you get a NameError. If it was defined, you would
still be iterating a boolean (which is not defined).

Grammatically, this is the following (just the important parts, again):
list_comprehension ::=  expression list_for
list_for ::=  "for" target_list "in" old_expression_list
old_expression_list ::= old_expression
old_expression ::= <stripped test hierarchy...> comparison
comparison ::= or_expr ( comp_operator or_expr )*
comp_operator ::= "in"

So your basic misconception is that both `in` keywords are belonging to
the list comprehension syntax -- the former does while the latter is
simply an operator.
History
Date User Action Args
2008-04-01 20:04:44lehmannrosetspambayes_score: 0.585912 -> 0.5859124
recipients: + lehmannro, kousu
2008-04-01 20:04:44lehmannrosetspambayes_score: 0.585912 -> 0.585912
messageid: <1207080284.05.0.876108272174.issue2529@psf.upfronthosting.co.za>
2008-04-01 20:04:42lehmannrolinkissue2529 messages
2008-04-01 20:04:41lehmannrocreate