lexical closures and python

Fredrik Lundh fredrik at pythonware.com
Thu Sep 6 03:44:17 EDT 2001


John Beppu wrote:

> My understanding is that Python does not support lexical closures.
> I've also heard that it should not be expected to appear any time
> in the near future.  Can anyone confirm or deny this?

nested scopes were introduced in Python 2.1.  For an
overview, see section 6 of this document:

    http://www.amk.ca/python/2.2/index.html

more details here:

    http://python.sourceforge.net/peps/pep-0227.html

> It seemed strange to me that of all these languages, Python was the
> one that didn't support lexical closures.

python has always supported *explicit* lexical scoping (via
default-value binding).  In 2.1 and later, you can leave that
to the compiler.

</F>





More information about the Python-list mailing list