[Tutor] New-style classes

Alan Gauld alan.gauld at blueyonder.co.uk
Sun Nov 2 13:44:54 EST 2003


> I have heard about new-style classes, and I'm afraid
> I'm using old-style classes 

Don't be afraid, old style classes are still what most 
of us use!

> Could somebody please explain what
> new-style classes are and their benefit over old-style

Simply put new style classes turn every type in Python 
into a class. This means that you can now sub class the 
standard types like int, float ot string. I believe there 
are a few exeptions - you can't (yet) subclass a 
function.

In practice thee are very few occasions when you will 
need new style classes, but its nice to know that if 
you do, you can...

But its definitely in the "advanced topics" category, you
can get into serious complexity when you statrt subtyping 
the basic types in any language.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list