any ways to judge whether an object is initilized or not in a class

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Tue Mar 20 13:37:24 CET 2007


On Tue, 20 Mar 2007 10:28:10 +0100, Bruno Desthuilliers complained about
classic classes:

>> What's wrong with old-style classes?
> 
> Almost everything. 

That's rather an exaggeration, don't you think? They have methods, and
inheritance, and attributes, all the critical features of classes, and
work perfectly well even if they don't support the more advanced features.


>> - Documentation on old style classes is more extensive.
> 
> Since new-style classes are backward compatible with old-style ones, 

Then "almost everything" is wrong with new style classes too? *wink*


> almost all the old-style classes documentation applies to new-style ones 
> as well. Everything else is quite well documented too:
> http://www.python.org/doc/newstyle/

On that very page, the first sentence says:

"Unfortunately, new-style classes have not yet been integrated into
Python's standard documention."

complete with spelling mistake.


>> On the minus side:
>> 
>> - Properties don't work as you expect them too.
> 
> properties don't work. Period. Properties rely on the descriptor 
> protocol, which only works with new-style classes.

Non-data descriptors (e.g. properties with only a getter) work fine. It is
only data descriptors (those with both a getter and a setter) that don't
work correctly.


>   - no metaclasses

Metaclasses worked all the way back in Python 1.5, although they were
painful and brain-exploding.

http://www.python.org/doc/essays/metaclasses


>   - no classmethod

Guido's own documentation for classmethods and staticmethods uses classic
classes. See

http://www.python.org/download/releases/2.2.3/descrintro/#staticmethods

But don't just take his word for it, try it for yourself *wink*



-- 
Steven




More information about the Python-list mailing list