__bases__ and type()
Daniel Silva
dansilva at lynx.dac.neu.edu
Mon Nov 18 22:16:52 EST 2002
Hello,
I am implementing a python compiler and got a bit confused about the
hierarchy of things in python. I assumed I could have one structure
(call it node) with three fields: parents (a list of nodes), dict (a
hash-table), and is_mutable.
I would then create an instance of a node with no parents and call it
object.
The basic types: int, float, string, none, dict, list, function, class,
instance, tuple, etc.. would then have object as the single item in the
list of parents.
User-built classes would have class as its only parent if they do not
have inheritance, and a list of super-classes in case they do.
However, given a class C, class D, and a class E that inherits from both
C and D, type(e) evaluates to ClassType, and e.__bases__ evaluates to
(c,d).
Did I get the organization of things incorrectly? How else should I
organize it for type(), __bases__, and isinstance() to work as expected?
-----------------------------------
Daniel Silva
dsilva at ccs.neu.edu
More information about the Python-list
mailing list