[Twisted-Python] Inheriting t.a.service.Service and super

Jean-Paul Calderone exarkun at divmod.com
Tue Mar 20 10:13:22 EDT 2007

On Tue, 20 Mar 2007 14:05:40 +0100, Sébastien LELONG <sebastien.lelong at dexia-securities.fr> wrote:
>I've been using Twisted for several months, and have frequently encountered
>the following problem.
>In my Twisted apps, I declare services (t.a.service.Service), which then I
>need to subclass. The problem is I can't call super() on such subclass, since
>the class Service in twisted does not inherit the built-in 'object' type
>("TypeError: super() argument 1 must be type, not classobj"). For now, I can
>use other form of superclass calling, but that can be error prone.
>Is there any particular reason why class Service isn't a subclass of object ?
>It's kind of surprising since Service is designed to be subclassed.
>Thanks in advance for your help/replies.

The major reason is backwards compatibility.  Changing a class to inherit
from object can break subclasses which didn't expect this.

The idea that's been discussed so far to address this is something along the
lines of adding an optional keyword argument to allow each user of the class
to specify whether it wants classic or new-style.  The default would be stay
classic for a while, then that would be deprecated, and finally it would be
an error not to ask for new-style (or maybe it would just become new-style
by default, but I don't like that so much).  Nothing's even nearly decided
yet though.  Suggestions are, of course, welcome. :)

You might find the information given here:


interesting as well, though (completely separate from whether Service is
new-style or not).


More information about the Twisted-Python mailing list