Inheritance issue...

MooMaster ntv1534 at gmail.com
Mon Mar 3 15:14:11 EST 2008


On Mar 3, 11:49 am, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> 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

Thanks guys, I hadn't even heard of the distinction between "old" and
"new" style classes...is this in the tutorial somewhere? I didn't see
it in Classes...



More information about the Python-list mailing list