On Feb 4, 2008 1:36 AM, 7stud <[EMAIL PROTECTED]> wrote: > print dir(type) #__mro__ attribute is in here > print dir(object) #no __mro__ attribute > > > class Mammals(object): > pass > class Dog(Mammals): > pass > > print issubclass(Dog, type) #False > print Dog.__mro__ > > --output:-- > (<class '__main__.Dog'>, <class '__main__.Mammals'>, <type 'object'>) > > > The output suggests that Dog actually is a subclass of type--despite > the fact that issubclass(Dog, type) returns False. In addition, the > output of dir(type) and dir(object): > > > ['__base__', '__bases__', '__basicsize__', '__call__', '__class__', > '__cmp__', '__delattr__', '__dict__', '__dictoffset__', '__doc__', > '__flags__', '__getattribute__', '__hash__', '__init__', > '__itemsize__', '__module__', '__mro__', '__name__', '__new__', > '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', > '__subclasses__', '__weakrefoffset__', 'mro'] > > ['__class__', '__delattr__', '__doc__', '__getattribute__', > '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', > '__repr__', '__setattr__', '__str__'] > > suggests that type inherits from object since type has all the same > attributes as object plus some additional ones. That seems to > indicate a hierarchy like this: > > > object > | > V > type > | > V > Mammals > | > V > Dog > > > But then why does issubclass(Dog, type) return False?
Here you should find The Answer (tm): http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html (Beautifully ilustrated, BTW) -- http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt -- http://mail.python.org/mailman/listinfo/python-list