Python/C API Inheritance

Stefan Behnel stefan_ml at
Wed Feb 2 18:55:37 CET 2011

Евгений Почитаев, 02.02.2011 18:21:
> May be someone do class inheritance in Python/C API, I know how create
> superclass/subclass. But how I can initialize superclass from subclass
> initializer?
> struct SuperClass {
>      PyObject_HEAD;
>      //...
> };
> struct SubClass {
>      PyObject_HEAD;

You need to insert the super class struct here, not a plain new object struct.

In case you want to avoid stumbling over problems like this and instead 
concentrate on getting functionality implemented, take a look at Cython.


More information about the Python-list mailing list