Times where one would use new style classes vs classic classes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Quek

    Times where one would use new style classes vs classic classes

    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.
  • Daniel Fetchinson

    #2
    Re: Times where one would use new style classes vs classic classes

    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

    Comment

    • Ben Finney

      #3
      Re: Times where one would use new style classes vs classic classes

      Quek <quekshuy@gmail .comwrites:
      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?
      Yes, it's the norm to use new-style classes. This makes one's classes
      part of the Python type hierarchy, allowing features such as 'super',
      'property', etc. to work correctly.

      Use new-style classes for any new code you create. Old-style classes
      are deprecated in Python 2.5 (even earlier than that I believe), and
      will be removed in Python 3.0
      <URL:http://wiki.python.org/moin/Python3.0>.

      --
      \ “Good judgement comes from experience. Experience comes from |
      `\ bad judgement.” —Frederick P. Brooks |
      _o__) |
      Ben Finney

      Comment

      • Bruno Desthuilliers

        #4
        Re: Times where one would use new style classes vs classic classes

        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.

        Comment

        • Quek

          #5
          Re: Times where one would use new style classes vs classic classes

          On Jul 3, 3:11 pm, Bruno Desthuilliers <bruno.
          42.desthuilli.. .@websiteburo.i nvalidwrote:
          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 mentionednewsty leand 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.

          Comment

          Working...