[Twisted-Python] Updated defer.html

Christopher Armstrong radix at twistedmatrix.com
Tue Mar 11 00:26:38 EST 2003

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

 Twisted | Christopher Armstrong: International Man of Twistery
  Radix  |          Release Manager,  Twisted Project
---------+     http://twistedmatrix.com/users/radix.twistd/

More information about the Twisted-Python mailing list