A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

Paul Rubin http
Sat Oct 14 02:57:26 EDT 2006


brenocon at gmail.com writes:
>     deferred = fetchPage('http://python.org')
>     def _showResponse(response)
>         print "fancy formatting: %s" % response.text
>     deferred.addCallback(_showResponse)
> 
> Lots of Twisted code has to be written backwards like this.

But that's just ugly.  The fetchPage function should take the callback
as an argument.  In an asynchronous system it would even be buggy.
What happens if the page fetch completes before you add the callback?



More information about the Python-list mailing list