Inheriting from object

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Jun 29 17:38:39 EDT 2005


Fuzzyman a écrit :
> Hello,
> 
> To create a classic (old style) class, I write :
> 
> class foo:
>     pass
> 
> To do the equivalent as a new style class, I write :
> 
> class foo(object):
>     pass
> 
> *Should* I in fact write :
> 
> class foo(object):
>     def __init__(self, *args, **kwargs):
>         object.__init__(self)
> 
> ?

Nope.

> Also, can anyone explain any tangible benefit of inheriting from
> object, when not explicitly using any features of new style classes ?

old-style classes are deprecated. They are still in the language (for 
how much time ?) for compatibility reasons, but they won't last forever. 
  That should be a good enough reason to avoid them,  given that the 
only thing you have to do is to inherit from object...



More information about the Python-list mailing list