[Tutor] a class query

Steven D'Aprano steve at pearwood.info
Mon Jun 7 18:11:10 CEST 2010


On Tue, 8 Jun 2010 01:12:28 am python at bdurham.com wrote:
> Not the OP, but I was surprised to see class Name() work (in Python
> 2.6.5 at least).
>
> Is this equivalent to class Name( object ) or does this create an old
> style class?

In Python 2.x, all classes are old-style unless you directly or 
indirectly inherit from object. If you inherit from nothing, it is an 
old-style class regardless of whether you say 

class Name: pass

or 

class Name(): pass

In Python 3.x, there are no old-style classes.

> Going forward into the 2.7/3.x world, is there a preferred style?

No.



-- 
Steven D'Aprano


More information about the Tutor mailing list