Is this a bug, or is it me?

Neil Cerutti mr.cerutti at gmail.com
Thu Jan 17 17:28:35 CET 2008


On Jan 17, 2008 11:08 AM,  <cokofreedom at gmail.com> wrote:
> On Jan 17, 4:59 pm, "Neil Cerutti" <mr.ceru... at gmail.com> wrote:
> > Generator expressions, unlike list comprehensions, have their own
> > scope so that they don't "leak" names to the enclosing scope. The
> > Python rule forbidding access to the locals of enclosing scopes is
> > preventing the class names from working in the generator expression.
>
> Ah, that explains why my random suggestion worked but was not
> helpful :) I feel like I am learning a lot today!

Me, too. Especially about wrongly oversimplifying stuff that's
complicated. My statement above isn't exactly right, since generator
expressions usually *can* access stuff in the enclosing local scope.
They wouldn't be very useful if they couldn't.

-- 
Neil Cerutti <mr.cerutti+python at gmail.com>



More information about the Python-list mailing list