__base__ and __bases__[0]

Michael Hudson mwh at python.net
Mon Apr 28 12:28:02 EDT 2003


mis6 at pitt.edu (Michele Simionato) writes:

> I thought __base__ and __bases__[0] where just equivalent, but it
> seems it is not so:
> 
> >>> class C(object): pass
> ...
> >>> class M(C,type): pass
> ...
> >>> M.__bases__[0]
> <class '__main__.C'>
> >>> M.__base__
> <type 'type'>
> 
> Question: how __base__ is computed and what's the rationale about it ?

It's found by the function best_base in typeobject.c.  I suggest you
read that...

Cheers,
M.

-- 
  We've had a lot of problems going from glibc 2.0 to glibc 2.1.
  People claim binary compatibility.  Except for functions they
  don't like.                       -- Peter Van Eynde, comp.lang.lisp




More information about the Python-list mailing list