Inheriting from object

Steven Bethard steven.bethard at gmail.com
Thu Jun 30 02:02:06 CEST 2005


Fuzzyman wrote:
> Surely when they are removed :
> 
> class foo:
>     pass
> 
> won't become invalid syntax, it will just automatically inherit from
> object ?

Well, Guido views this particular syntax as an "oopsie"[1].  It should 
actually look like:

     class C():
         pass

Guido also suggests that the explicit:

     class C(object):
         pass

is "much preferred"[2] over:

     __metaclass__ = type

     class C:
         pass

when creating new-style classes.  It's not exactly clear where Guido 
comes down on your particular issue, but if I had to guess, I would 
guess that he prefers the explicit reference to "object".

STeVe

[1]http://mail.python.org/pipermail/python-dev/2005-February/051706.html
[2]http://mail.python.org/pipermail/python-dev/2005-February/051711.html



More information about the Python-list mailing list