newb __init__ inheritance

Ian Kelly ian.g.kelly at
Sun Mar 11 12:40:53 CET 2012

On Sun, Mar 11, 2012 at 4:56 AM, hyperboogie <hyperboogie at> wrote:
> 1. What do you mean by "subclassing `object`"?

In Python 2 there are two different types of classes: classic classes,
which are retained for backward compatibility, and new-style classes,
which were introduced in Python 2.2.  Classic classes are the default.
 In order to get a new-style class (strongly recommended), your class
must inherit directly or indirectly from object.  In the following, A
and B are classic classes, whereas C and D are new-style classes:

class A: pass

class B(A): pass

class C(object): pass

class D(C): pass

In Python 3, classic classes have been removed, and so all four of the
classes above would be new-style.

> 2. Is the mro function available only on python3?

No, but it is available only on new-style classes.  If you try it on a
classic class, you'll get an AttributeError.


More information about the Python-list mailing list