On Aug 23, 2011, at 10:37 AM, Tobias Oberstein wrote:

> class AutobahnDeferred(Deferred):
>   def call(self, *args):
>      return self.addCallback(self.protocol.rcall, *args)
> 
> Pro:  most terse
> Con:  only supports single callback no errback

Con: subclassing in general is a bad idea.  Subclassing Deferred is an even 
worse idea.  What if Deferred one day gets a new method called 'call' that does 
something different?  Your code would all break.

> Anything why I shouldn't do?

Providing three different ways to do the same thing just so that you can use 
different syntax depending on your mood is a recipe for making your code hard 
to read.  Pick one style, stick to it as much as possible - consistency is more 
important than the benefits of any one particular style :).

(Except the subclassing one.  Don't do that.)

-glyph

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to