lexical closures and python

Andy Elvey andy.elvey at paradise.net.nz
Wed Sep 26 02:27:15 EDT 2001


John Beppu <beppu at binq.org> wrote in message
news:mailman.999755048.7248.python-list at python.org...
> Hi,
>
> 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?
>
> I want to know, because I'm writing a piece that talks a lot
> about Scheme, and I was comparing it to a lot of scripting languages
> that are out there -- Perl, Python, Ruby, and even JavaScript...
> It seemed strange to me that of all these languages, Python was the
> one that didn't support lexical closures.  (On the other hand, I was
> surpised to find out that JavaScript _did_ support lexical closures).
>
 It *is* indeed possible to do closures in Python !  See this article -
http://www-106.ibm.com/developerworks/library/l-prog.html

 and - http://www-106.ibm.com/developerworks/library/l-prog2.html  .

 ( This is a 2-part article - the second part of it (the 2nd URL given)
shows how to do closures.)
  This article gives an *excellent* intro to functional programming using
Python .   The code in these articles uses the "Xoltar toolkit" -
http://sourceforge.net/projects/xoltar-toolkit  -  which is itself written
in Python.







More information about the Python-list mailing list