On Class namespaces, calling methods

Aahz aahz at pythoncraft.com
Sun Apr 25 02:15:29 CEST 2010


In article <4bd2e204$1 at dnews.tpgi.com.au>,
Lie Ryan  <lie.1296 at gmail.com> wrote:
>On 04/24/10 06:07, Aahz wrote:
>> In article <4bc120bd$0$8850$c3e8da3 at news.astraweb.com>,
>> Steven D'Aprano  <steve at REMOVE-THIS-cybersource.com.au> wrote:
>>>
>>> I can only think of two circumstances where old-style classes are 
>>> *wrong*: if you use multiple inheritance with a diamond diagram ("...now 
>>> you have THREE problems" *wink*), if you intend using descriptors such as 
>>> properties, or if you need __slots__. That's three circumstances: 
>>> multiple inheritance with a diamond diagram, descriptors, __slots__, and 
>>> __getattribute__. Four circumstances.
>>>
>>> Any other time, they're merely discouraged, and gone in Python 3.x.
>> 
>> Discouraged by some people.  I certainly encourage the use of old-style
>> classes unless there's a specific reason to use new-style classes.
>
>For what reason?

Because it's simpler and because it allows people to write code that
works with 1.5.2+ if they want.  Admittedly, few people want to go back
that far, but lots of people are still using Python 2.2, and I prefer to
avoid new-style classes with 2.2 because of the changes in 2.3.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan



More information about the Python-list mailing list