new style and classic style classes ?

A

ankit

Hello,
Please put some light on, What are new style classes and classic style
classes in python. The basic differences in them. And How can I decide
to choose one.
 
A

Alex Martelli

ankit said:
Hello,
Please put some light on, What are new style classes and classic style
classes in python. The basic differences in them. And How can I decide
to choose one.

"Classic" (old-style) classes are ones with no ancestor classes that are
built-in types; "new-style" classes are one with ancestor classes that
are built-ins (including the built-in type 'object', which exists for
the sole purpose of making classes new-style). New-style classes have a
clearer and better organized approach to attribute access, and allow you
to use such powerful features as 'property' to full effect.

Old-style classes exist only for backwards compatibility. The only good
reason to decide to make a class old-style is when you're making an
*exception* class, specifically: up to Python 2.4, exception classes
must be old-style.


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top