Robert Lehmann <[EMAIL PROTECTED]> added the comment: 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. ---------- nosy: +lehmannro __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2529> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com