Struct usages in Python

Diez B. Roggisch deets at nospam.web.de
Wed May 28 13:46:16 EDT 2008


Alex Gusarov schrieb:
>>  class Event(object):
>>
>> Always subclass object, unless you have a very compelling reason not to,
>> or you are subclassing something else.
>>
> 
> I've thought that if I write
> 
> class Event:
>     pass
> 
> , it'll be subclass of object too, I was wrong?


Yes. That is the somewhat unfortunate difference between new-style and 
old-style classes. Use new-style if you can, and that means that 
"object" must be part of the inheritance graph.

http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html

Diez



More information about the Python-list mailing list