class C: vs class C(object):

Aahz aahz at pythoncraft.com
Sat Jul 21 09:26:31 EDT 2007


In article <46a082ed$0$431$426a74cc at news.free.fr>,
Bruno Desthuilliers  <bruno.42.desthuilliers at wtf.websiteburo.oops.com> wrote:
>Aahz a écrit :
>> In article <469f1557$0$26759$426a74cc at news.free.fr>,
>> Bruno Desthuilliers  <bruno.42.desthuilliers at wtf.websiteburo.oops.com> wrote:
>>>
>>> To make a long story short: Python 2.2 introduced a new object model 
>>> which is more coherent and more powerful than the original one. The old 
>>> one was kept so far for compatibility reasons, but there's absolutely no 
>>> reason to use it no more since "new-style" classes can do anything 
>>> "Classic" classes did and much more. IOW, don't even bother with 
>>> old-style classes.
>> 
>> And I'll make my usual knee-jerk response disagreeing with this.  For
>> more info, search groups.google.com.
>
>And you'll still make it harder for newcomers to understand why a lot of 
>things don't work correctly with their classes. How helpful...

Enh.  *All* of the standard Python documentation currently starts with
teaching classic classes, so it seems to me that this comment in fact
points toward difficulty understanding why things don't work correctly in
new-style classes.

>Aahz, the object model switch happened *years* ago, and it's quite
>clear that old style classes have been kept so far for compatibility
>reasons only. It's obvious that one doesn't gain *anything* - except
>compat with years-old pre-2.2 versions of Python - using old-style
>classes. So *why* on earth are you still *advocating* the use of old
>style classes ??????

Saying that I'm "advocating" the use of old-style classes is not
precisely correct.  The simple fact is that you are wrong about the
switch having happened already.  There is almost no basic documentation
that starts with new-style classes; the vast majority of the Python
Standard Library still uses classic classes; there is no requirement in
PEP8 that new code for adding into Python 2.x use new-style classes.

Moreover, there are still plenty of people (me included) who use Python
2.2 for production purposes, and because of the small but critical
differences between new-style classes in 2.2 and 2.3+, I cannot
recommend new-style classes for anyone who has not switched to using
only 2.3+.  (For that matter, there are still people using 2.1 and
earlier, which is why some developers such as Fredrik Lundh still support
all the way back to 1.5.2.)

*YOU* are the one confusing people by your dogmatic insistance that
classic classes should be ignored.  Grow up.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

I support the RKAB



More information about the Python-list mailing list