On Mar 15, 5:31 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > The fact that a list comprehension "leaks" its variables into the > containing scope is a bit weird. > A generator expression doesn't: > > py> str > <type 'str'> > py> w = (str for str in range(10)) > py> w > <generator object at 0x00AD7C38> > py> str > <type 'str'> > py> w.next() > 0 > py> str > <type 'str'>
On Mar 15, 5:34 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > or: > > methodList = list(str for str in names if callable(getattr(obj, str))) > > genexps, unlike listcomps, make a new scope for their index variable. Thanks. -- http://mail.python.org/mailman/listinfo/python-list