new style and classic style classes ?

Discussion in 'Python' started by ankit, Dec 22, 2005.

  1. ankit

    ankit Guest

    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.
     
    ankit, Dec 22, 2005
    #1
    1. Advertising

  2. ankit <> wrote:

    > 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
     
    Alex Martelli, Dec 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris S.

    Classic and New Style Classes?

    Chris S., Jun 24, 2004, in forum: Python
    Replies:
    5
    Views:
    378
    Chris S.
    Jun 24, 2004
  2. Skip Montanaro
    Replies:
    0
    Views:
    280
    Skip Montanaro
    Jul 16, 2004
  3. Max Derkachev
    Replies:
    4
    Views:
    689
    Jack Diederich
    May 5, 2005
  4. Isaac Rodriguez

    Are all classes new-style classes in 2.4+?

    Isaac Rodriguez, Dec 31, 2006, in forum: Python
    Replies:
    4
    Views:
    398
    Steven D'Aprano
    Dec 31, 2006
  5. Quek
    Replies:
    3
    Views:
    347
Loading...

Share This Page