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

Georg Brandl report at bugs.python.org
Sun Mar 2 22:07:47 CET 2008


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 the whole genexp.

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


More information about the Python-bugs-list mailing list