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

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Mon Mar 19 23:41:26 EDT 2007


On Mon, 19 Mar 2007 19:48:37 +1100, Ben Finney wrote:

> It's also best to inherit every class from another class, leading to a
> single hierarchy for all classes and types. 'object' is the one to
> choose if you don't want the behaviour of any other class.

What's wrong with old-style classes?

On the plus side:

- Why inherit from something if you don't need to?

- Less typing.

- Attribute-lookup is much faster, perhaps as much as twice as fast.
http://www.python.org/~jeremy/weblog/030506.html

- Documentation on old style classes is more extensive.

- You can't use new style classes for exceptions.



On the minus side:

- Properties don't work as you expect them too.

- Slots don't work at all.


In other words, the only reason why you HAVE to use a new style class is
that you need properties or __slots__. You might WANT to use a new style
class to inherit from built-in types. Otherwise, the choice between old
and new is not very important.



-- 
Steven.




More information about the Python-list mailing list