Inheritance issue...

Diez B. Roggisch deets at nospam.web.de
Mon Mar 3 13:49:20 EST 2008


MooMaster schrieb:
> I'm trying to use inheritance to create a simple binary tree, but it's
> not going so well... here's what I pull from the documentation for
> super()
> "super( type[, object-or-type])
> 
> Return the superclass of type. If the second argument is omitted the
> super object returned is unbound. If the second argument is an object,
> isinstance(obj, type) must be true. If the second argument is a type,
> issubclass(type2, type) must be true. super() only works for new-style
> classes.

The last sentence contains the important bit. You need to use 
new-style-classes, which means they have to have the ancestor "object" 
somewhere in their inheritance-graph.

Like this:

class Foo(object): pass

Certainly one of the somewhat uglier corners of Python...

Diez



More information about the Python-list mailing list