Trying to understand Python objects

Bruno Desthuilliers bdesth.quelquechose at
Thu Nov 23 21:01:31 CET 2006

Aahz a écrit :
> In article <mailman.564.1164158130.32031.python-list at>,
> Ben Finney  <bignose+hates-spam at> wrote:
>>Typically, classes are created as a subclass of another class. The
>>top-level basic type in Python is 'object', so if your class doesn't
>>make sense deriving from anything else, derive from 'object'.
>>   class Point(object):
>>       pass
>>Defining a class with *no* superclass is not recommended. If you don't
>>yet understand the difference between the above style (called a
>>"new-style" class) and the style you presented, you should always
>>derive from a superclass ('object' or something more specific) until
>>you encounter a situation where that causes a problem.
> Side note: I disagree with the above advice, but it's Thanksgiving and I
> don't have enough room on the margin for the proof.  I think classic
> classes are just fine.

Don't see it as a religious point please, but I fail to understand why 
you seem so in love with old-style classes ? new-style classes are the 
"official" Python object model since 2.2 (which is a few years ago now), 
and the last mandatory use of them (exceptions...) disappeared with the 
2.5. AFAIK, everything you do with old-style classes can be done with 
new-style ones. FWIW, old-style classes support is now only for backward 
compat. So *why* insisting on using them ?


More information about the Python-list mailing list