Re: lambda construction
Thu, 23 Jun 1994 09:59:08 +0200

> > I was confused in thinking that the global name space for the lambda
> > ... was the local name space of the wrap function ...

> It's a common confusion! Now you know why I'm keen to change the "fact
> sheet" to reduce the explanation of the global NS to the one-line truth.
> The ref manual's table is accurate but misleading: all the "NS of
> containing block" and "NS of caller" entries in the Global column
> strongly imply "ah, so the global NS nests!" to the (even not so) casual
> reader.
> Replace all that with "the global NS is the module NS", and all the
> "containing block" entries in the entire table vanish. Without those,
> erroneous ideas about Python's scope nesting are harder to fall into.

I agree there's a confusion. I know the reference manual isn't the
most well read of Python manuals (which is partly my fault for making
it somewhat awkward to read), but maybe the situation would be
somewhat improved if I added the following to the text leading up to
that particular table:

Note that in almost all cases, the global name space is
the name space of the containing module -- scopes in Python do not

I could also simply say "global namespace of containing module" in the
table and add a note that if there's no containing module it's still
inherited, but that seems inappropriate for a reference manual...

> BTW, some people who believe that arbitrary nesting of scopes is
> essential program in Python for years before they realize Python doesn't
> support it <0.8 grin>. The introduction of "lambda" seemed to make this
> realization occur a lot earlier than it used to, though.

Yes, since lambda was introduced I indeed do get more questions about
this. I guess lambda means more to most Lisp'ers than I knew. I
still maintain that it's not that much of an addition to the language
and wish I hadn't introduced it...

> paul-mccartney-was-in-a-band-before-wings?!-ly y'rs - tim

Who is Paul McCartney?

--Guido van Rossum, CWI, Amsterdam <>
URL: <>