Choosing new-style vs classic classes (was Re: any ways to judge whether an object is initilized or not in a class)

Aahz aahz at
Tue Mar 20 18:32:40 CET 2007

In article <pan.2007. at>,
Steven D'Aprano  <steve at> wrote:
>On Tue, 20 Mar 2007 08:27:07 -0700, Alex Martelli wrote:
>> You should always use new-style classes in order to avoid having to stop
>> and make a decision each time you code a class -- having to stop and ask
>> yourself "do I need any of the many extra features of new-style classes
>> here, or will legacy classes suffice?" each and every time.
>I can sympathize with your argument. I have taught myself to _always_
>indicate when turning the car, even when I don't need to. I do it without
>thinking, even when turning from my own driveway into my garage (much to
>my wife's amusement). And that way, I don't have to think on the road "do
>I need to indicate now or not?", I just do it.
>Rather than keep arguing my case (life is short...) I'll just mention that
>both Fredrik Lundh and Aahz were very dismissive of the suggestion that
>people should stop using classic classes back in July 2005.
>e.g. Aahz wrote: "There's a big difference between being gung-ho on
>new-style classes and telling people to stop using old-style classes."
>Have they changed their mind since then? Not that I'm suggesting that
>their opinions outweigh Alex's, but I'm not sure that the situation
>vis-a-vis classes has changed that much since 2005. If it has, perhaps I
>should be revising my opinion too.

My mind has not changed, and it has since been enshrined in _Python for
Dummies_.  ;-)  One point that I should make clear, because I think it
plays a large part of why Fredrik and I differ from Alex: my code at work
still runs on Python 2.2, which I believe should be avoided for heavy use
of new-style classes.  (The differences in new-style classes between 2.2
and later versions are small but significant, and I *don't* want to have
to think about them because we also use 2.3 at work.)  I believe Fredrik
still supports Python 1.5.2.  If you only support 2.3 and later,
suggesting a complete switchover to new-style classes becomes more

Moreover, my codebase at work started with Python 1.4, and upgrading it
all to correctly work with new-style classes would be a monumental
undertaking.  From my POV, as long as the bulk of the standard library is
still based on classic classes, that undertaking is not worth it.

I'm not quite as habitual as you are about turn signals, but I'm pretty
Aahz (aahz at           <*>

"Typing is cheap.  Thinking is expensive."  --Roy Smith

More information about the Python-list mailing list