New-style classes questions

Kalle Anke skromta at gmail.com
Sun Sep 25 04:15:18 EDT 2005


I'm confused by the concepts of old-style vs new-style classes, I've read 
most of the documents I found about this but it doesn't "click". Probably 
because I wasn't around before 2.2.

Anyway, the reason for new style classes are to make the whole type/object 
thing work better together. There are a number of new features etc.

I think my problem is when new-style classes are used, at first I thought 
that all classes become new-style classes when I was using 2.4, but if I 
understand things correctly I need to subclass an existing class (assuming 
that this class does the same) for it to become a new-style class.

Have I understood this correctly?

If I have, then I've got the following question:
================================================
Then I could write:

  class Foo( Object )

to make a new-style class, and 

  class FooA

to make an old-style class.


What is the reason for allowing both styles? (backwards compatibility??) 

When I make my own classes should they always be new-style objects or are 
there reasons for using old-style object?
================================================





More information about the Python-list mailing list