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

Duncan Booth duncan.booth at invalid.invalid
Sat Oct 14 10:51:30 CEST 2006

Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:

> 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?

Or it should be trivial to give deferred a decorator method and write:

def _showResponse(response):

More information about the Python-list mailing list