[Twisted-Python] Using decorator syntax in Twisted
Until now we haven't AFAIK used decorator syntax, but I think it's time we start to. In places where we were already using decorators without the special syntax, that is. Consider: def foo(cls, arg): # lalalal foo = classmethod(foo) One has to type "foo" three times (a potential source of error), and the special semantics of the function are known to the reader only *after* reading the function. On the other hand: @classmethod def foo(cls, arg): # lalalal This suffers from none of these problems. Any disagreement?
On 03:24 pm, itamar@itamarst.org wrote:
Until now we haven't AFAIK used decorator syntax, but I think it's time we start to. In places where we were already using decorators without the special syntax, that is.
Consider:
def foo(cls, arg): # lalalal foo = classmethod(foo)
One has to type "foo" three times (a potential source of error), and the special semantics of the function are known to the reader only *after* reading the function. On the other hand:
@classmethod def foo(cls, arg): # lalalal
This suffers from none of these problems.
Any disagreement?
Can we start with a limited experimental usage? Some new code can be written this way, and we'll see if there's any negative feedback following the next release. I don't want existing code to get ported to the new syntax just because it's possible now. Jean-Paul
participants (2)
-
exarkun@twistedmatrix.com
-
Itamar Turner-Trauring