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:13:30 CET 2007


On Tue, 20 Mar 2007 10:28:10 +0100, Bruno Desthuilliers wrote:

[deploying weapons of mass snippage]

>> Otherwise, the choice between old
>> and new is not very important.
> 
> Your opinion. Too bad you're missing some of the most powerful parts of 
> the language.

Yes, it is my opinion, and it seems that in your zeal to defend new-style
classes against an imaginary attack, you've completely misunderstood what
my opinion is.

I'm not against new-style classes. I do use new-style classes. There are a
whole lot of extra features that new-style classes have that old-style
classes don't have, some of which I didn't even think of. (Thanks for
pointing them out, and I'm not being sarcastic.)

There are plenty of reasons for preferring new style classes. If those
reasons hold for you, then of course you should use new style classes.

But that's not the same thing as saying that you should use new style
classes *even when you don't care about those features*.

I never once suggested that new style classes are unnecessary, or a waste
of time, or bad, or whatever else you seem to think I was saying. My point
was, if you don't _need_ a new style class, there is no reason to avoid
using an old style class. It is a purely personal choice.

There seems to be a misunderstanding that classic classes have been
depreciated. They certainly have not. We've been told that old style
classes will "eventually" disappear, "probably" in Python 3. That is not
the same thing at all. The docs are very careful to avoid saying that old
style classes are depreciated.

(See, for example http://docs.python.org/ref/node33.html)

What I predict is that under the hood, Python 3 will complete the job of
unifying types and classes. The distinction between classic classes and
new style classes will go away. All classes will behave the same, whether
you write "class X:" or "class X():" or "class X(object):" or whatever
syntax Python 3 uses for defining classes.



-- 
Steven.




More information about the Python-list mailing list