John Nagle wrote:

>     Most of the examples given here are kind of silly, but closures have
> real uses.  I used one today in Javascript because I was writing an
> AJAX application, and I was using an API, the standard XMLHttpRequestObject,
> which required a callback function with no arguments.  A closure allowed
> the code to pass relevant information with the callback function, which
> would be called when a request to the server completed.  A global
> variable wouldn't have worked, because multiple instances of the object
> making the callback are possible.

the usual way of handling multiple callback context instances in Python 
is of course to create multiple instances of the class that implements 
the behaviour, and use a bound method as the callback.

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to