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

Christoph Zwerschke report at bugs.python.org
Sun Mar 2 20:47:00 CET 2008


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 generator expression is equivalent
to the following code which works fine:

class A:
    a = 'test'
    def __g(a):
        for c in a:
            if c in a:
                yield c
    tuple(__g(a))

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2217>
__________________________________


More information about the Python-bugs-list mailing list