[issue2217] Problem with if clause in generator expression on class level

2008-03-03 Thread Georg Brandl
Georg Brandl added the comment: Good idea! I've committed these changes in r61212. __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bugs-list mailing list U

[issue2217] Problem with if clause in generator expression on class level

2008-03-02 Thread Christoph Zwerschke
Christoph Zwerschke added the comment: Thanks, this now makes sense to me. You're right, it's rather an ugly wart than a bug. But I think the Python reference needs to be improved to make this clear enough. How about the following proposed addtions (in square brackets) to section 5.2.5 (http://

[issue2217] Problem with if clause in generator expression on class level

2008-03-02 Thread Georg Brandl
Georg Brandl added the comment: The actual equivalent would be class A: a = 'test' def __g(_x): for c in _x: if c in a: yield c tuple(__g(a)) i.e. the outmost iterator is evaluated in the enclosing scope; not the if clause is in its own scope, but

[issue2217] Problem with if clause in generator expression on class level

2008-03-02 Thread Christoph Zwerschke
Christoph Zwerschke added the comment: Thanks for the quick explanation. I understand that class scopes don't extend and this is documented behavior. However, the question is why the if clause is executed in a scope of its own and where this is documented. You would expect that the problematic

[issue2217] Problem with if clause in generator expression on class level

2008-03-02 Thread Georg Brandl
Georg Brandl added the comment: This may seem odd, but is correct as per spec. The "if c in a" part is executed in a scope of its own, and class scopes don't contribute to nested scoping. -- nosy: +georg.brandl resolution: -> wont fix status: open -> closed ___

[issue2217] Problem with if clause in generator expression on class level

2008-03-02 Thread Christoph Zwerschke
New submission from Christoph Zwerschke: The following code throws a NameError which seems to be a bug existing since Python 2.4 up to the current 2.5.2. class A: a = 'test' [c for c in a] (c for c in a) tuple(c for c in a) [c for c in a if c in a] (c for c in a if c in a