[Twisted-Python] Updated defer.html

Bob Ippolito bob at redivi.com
Tue Mar 11 02:07:19 EST 2003

On Tuesday, Mar 11, 2003, at 00:26 America/New_York, Christopher 
Armstrong wrote:

> On Mon, Mar 10, 2003 at 09:36:30PM -0500, Bob Ippolito wrote:
>> class Passthrough:
>> 	def __init__(self, fn):
>> 		self.fn = fn
>> 	def __call__(self, result, *args, **kwargs):
>> 		self.fn(*args, **kwargs)
>> 		return result
>> Is something like that worthy of sitting in defer.py ?
> Well, for one, it could be implemented like this:
>   def passThrough(fn):
>       return lambda *args, **kwargs: fn(*args, **kwargs)
> for two, I don't think it's worth it when people can just in-line a
> similar lambda into their code. I use stuff like this all the time:
>   d.addCallback(lambda r: foo(bar, baz))

Yeah but that doesn't pass the result through to the next deferred in 
the callback chain, that passes on whatever fn() returns.. which could 
very well be just None.  For most cases that's ok, but not for all.


More information about the Twisted-Python mailing list