[Twisted-Python] addCallbacks issue

Andrew Bennetts andrew-twisted at puzzling.org
Wed Apr 14 19:11:28 MDT 2004


On Tue, Apr 13, 2004 at 09:57:10PM +1000, Stephen Thorne wrote:
> 
> Maybe by making a parallel to imperitive style we can make it clearer.
> 
> d = op()
> d.addCallbacks(callback, errback)
> 
> is equivilient to
> 
> try:
>     r = op()
> except e:
>     return errback(e)
> else:
>     return callback(r)

The exact same thought occurred to me recently while I was lying in bed (and
resolutely trying to go to sleep and not get up and send/read more email ;).  My
only reservation is that some people might not be familiar with the
try/except/else construct, but I suppose an appropriate link to the Python
docs (probably a section of the Python tutorial?) can solve that.

-Andrew.





More information about the Twisted-Python mailing list