[Twisted-web] Old Style python classes in Twisted

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sat Oct 6 17:50:10 EDT 2012

On 09:22 pm, ardesai at yahoo.com wrote:
>Given that twisted tutorials and other written materials show examples 
>of derived classes for Protocol, HTTP Request etc., is there a good 
>reason for many classes (almost all I suspect) (e.g. 'class Request' , 
>'class BaseProtocol',  'class _PauseableMixin', etc.) to be old style 
>classes as opposed to a new style python classes?
>Given that newer versions of twisted (and user apps) run on newer 
>versions of python, I initially (a few years ago) tried to call the 
>base class using super(), but was surprised to find twisted implements 
>using old style classes.
>New style classes make it easy to call a base class method (by using 
>super).  Would the MRO in new style classes make it better or worse? 
>However, nothing wrong with old style classes, esp. if twisted depends 
>on the depth-first MRO of old style classes.
>Can someone clarify whether use of old style classes is intentional 
>(e.g. due to MRO)?

It is intentional in case any applications based on Twisted rely on 
behavior of classic classes, such as the MRO differences.  Classes added 
to Twisted now are all new-style, though.


More information about the Twisted-web mailing list