[Twisted-Python] Another nit on "Generalization of Deferred Execution in Python"

Patrick K. O'Brien pobrien at orbtech.com
Fri Jan 17 13:32:36 MST 2003


On Friday 17 January 2003 09:34 am, Tommi Virtanen wrote:
>         http://cumulo-nimbus.mit.edu/deferex.xhtml
>
> 	You call this "pretty"?
>
> def prettyRequest(server, requestName):
>     return server.makeRequest(requestName
>                               ).addCallback(
>         lambda result: ', '.join(result.asList())
>         ).addErrback(
>         lambda failure: failure.printTraceback())
>
> 	How about
>
> def prettyRequest(server, requestName):
>     d=server.makeRequest(requestName)
>     d.addCallback(lambda result: ', '.join(result.asList()))
>     d.addErrback(lambda failure: failure.printTraceback())
>     return d
>
> 	I'm pretty sure everyone will consider that more readable.

You've raised an issue I've wondered about as I've looked at some of the 
Twisted source. There seems to be a fondness for returning large 
expressions, rather than building up a return value in a more piecemeal 
(and more easily read and understood) fashion. Is this simply a matter of 
style, or is there something substantial going on here related to the 
nature of Twisted? My own code tends to look more like your second example.

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------





More information about the Twisted-Python mailing list