When to derive from object?

Matimus mccredie at gmail.com
Tue Oct 13 11:02:39 EDT 2009


On Oct 13, 7:45 am, Igor Mikushkin <igor.mikush... at gmail.com> wrote:
> Hello all!
>
> I'm a newbie to Python.
> Could you please say me when it is better to derive from "object" and
> when not?
>
> Thanks,
> Igor

The only reason to derive from 'object' is if there is some sort of
weird side effect of using new style classes. I _have_ run into some
interesting scenarios when creating com objects in python using the
win32com module. Other than that, I always use new style classes
(derived from object).

Here are some articles that point out the distinctions between old and
new style classes: http://python.org/doc/newstyle/

Matt



More information about the Python-list mailing list