7stud <[EMAIL PROTECTED]> writes:

> On Feb 4, 12:49 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
>> 7stud <[EMAIL PROTECTED]> writes:
>> > --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.
>>
>> What was it in the output that gave you the impression that Dog is a
>> subclass of type?
>
> The fact that Dog.__mro__ produces any output at all--instead of
> producing an error.  object does not have an __mro__attribute, so
> where did Dog inherit that attribute from?  The output of dir(type)
> shoes that type has an __mro__ attribute.

I see some confusion.

For one, while Dog is not a subclass of type, it's certainly an
*instance* of type.  All instances of type have an __mro__ instance,
including object, regardless of whether dir() is aware of it.  (Try
object.__mro__, it evaluates just fine.)

Second, simply the fact that an object has an attribute doesn't say
anything about its chain of inheritance.  The final word on
inheritance is the contents of attributes such as __bases__ (shallow)
and __mro__ (deep).
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to