Times where one would use new style classes vs classic classes

Discussion in 'Python' started by Quek, Jul 3, 2008.

  1. Quek

    Quek Guest

    Hi all,

    I'm really new to Python and I've been reading up some texts on older
    versions of Python (2.2 to be specific).

    The text briefly mentioned new style and classic classes.

    I'd really like to know in the current context of Python 2.5, besides
    in the cases of multi-inheritance, where would I use new style
    classes? Is it a norm to use more new style classes even if I don't
    have multi-inheritance in the industry, open source projects, etc
    today?

    If this isn't the right place to ask these questions, could some one
    point me somewhere more appropriate?

    Thanks a lot.
     
    Quek, Jul 3, 2008
    #1
    1. Advertising

  2. > I'm really new to Python and I've been reading up some texts on older
    > versions of Python (2.2 to be specific).
    >
    > The text briefly mentioned new style and classic classes.
    >
    > I'd really like to know in the current context of Python 2.5, besides
    > in the cases of multi-inheritance, where would I use new style
    > classes? Is it a norm to use more new style classes even if I don't
    > have multi-inheritance in the industry, open source projects, etc
    > today?
    >
    > If this isn't the right place to ask these questions, could some one
    > point me somewhere more appropriate?


    As a general rule one always uses new style classes. In fact, in
    python 3.0 old style classes will cease to exist which fact alone
    justifies their abandonment from 2.x code too.

    Cheers,
    Daniel
    --
    Psss, psss, put it down! - http://www.cafepress.com/putitdown
     
    Daniel Fetchinson, Jul 3, 2008
    #2
    1. Advertising

  3. Quek a écrit :
    > Hi all,
    >
    > I'm really new to Python and I've been reading up some texts on older
    > versions of Python (2.2 to be specific).
    >
    > The text briefly mentioned new style and classic classes.
    >
    > I'd really like to know in the current context of Python 2.5, besides
    > in the cases of multi-inheritance, where would I use new style
    > classes?


    Everywhere you don't have to support compat with ages-old versions of
    Python. MI is not the main point of newstyle classes (FWIW, you can do
    MI with old-style classes too), they have quite a lot more to offer.
    Consider "classic" classes as a legacy feature, period.
     
    Bruno Desthuilliers, Jul 3, 2008
    #3
  4. Quek

    Quek Guest

    On Jul 3, 3:11 pm, Bruno Desthuilliers <bruno.
    > wrote:
    > Quek a écrit :
    >
    > > Hi all,

    >
    > > I'm reallynewto Python and I've been reading up some texts on older
    > > versions of Python (2.2 to be specific).

    >
    > > The text briefly mentionednewstyleand classic classes.

    >
    > > I'd really like to know in the current context of Python 2.5, besides
    > > in the cases of multi-inheritance, where would I usenewstyle
    > > classes?

    >
    > Everywhere you don't have to support compat with ages-old versions of
    > Python. MI is not the main point of newstyle classes (FWIW, you can do
    > MI with old-styleclasses too), they have quite a lot more to offer.
    > Consider "classic" classes as a legacy feature, period.


    Thanks everyone.
     
    Quek, Jul 3, 2008
    #4
    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:
    390
    Chris S.
    Jun 24, 2004
  2. Skip Montanaro
    Replies:
    0
    Views:
    284
    Skip Montanaro
    Jul 16, 2004
  3. ankit
    Replies:
    1
    Views:
    367
    Alex Martelli
    Dec 22, 2005
  4. Kza
    Replies:
    4
    Views:
    439
    Andrew Koenig
    Mar 3, 2006
  5. Peng Yu
    Replies:
    17
    Views:
    730
    Peng Yu
    Sep 14, 2008
Loading...

Share This Page