"Maric Michaud" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
|I faced a strange behavior with generator expression, which seems like a 
bug, for both
| python 2.4 and 2.5 :

Including the latest release (2.5.2)?

| >>> class A :
| ...     a = 1, 2, 3
| ...     b = 1, 2, 3
| ...     C = list((e,f) for e in a for f in b)
| ...
| Traceback (most recent call last):
|  File "<stdin>", line 1, in <module>
|  File "<stdin>", line 4, in A
|  File "<stdin>", line 4, in <genexpr>
| NameError: global name 'b' is not defined

If you switch 'a' and 'b' in the expression, it will be 'a' that is not 
defined.
There was/is a known issue with generator expressions (but not list comps) 
treating 'for' clauses after the first differently from the first in 
respect to variable resolution.  I believe I have seen this discussed on 
PyDev list.  But I searched the bugs.python.org for 'generator expression' 
and '_ _s' and got no relevant hits.

| Any comment ? I'm ready to report it as a bug if there is no objection.

If this is in 2.5.2, (and not one else objects), go ahead.

tjr



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to