Re: class(object) and (type)??

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

    Re: class(object) and (type)??

    Subclassing 'object' makes the class new-style as opposed to
    old-style. object is the ultimate superclass of all new-style classes.
    Old-style classes are deprecated and will be removed in Python 3.0,
    but they're currently the default for backward-compatibility reasons.
    See http://docs.python.org/ref/node33.html for more info.

    - Chris

    On Mon, Sep 8, 2008 at 2:35 PM, AON LAZIO <aonlazio@gmail .comwrote:
    Hi again pythoners,
    I notice in the class of a code having (object) and (type) attached to
    the name of the class.
    I know that in other cases, that means the class inherits methods and
    properties from other but
    In this case, what does it mean?
    For example,
    >
    class PY(object):
    def __init__(self):
    ...
    >
    class PO(type):
    def __init__(self):
    ...
    What do "object" and "type" mean?
    >
    Thanks in advance
    >
    Aonlazio
    >
    --

    >


    --
    Follow the path of the Iguana...

  • Bruno Desthuilliers

    #2
    Re: class(object) and (type)??

    On Mon, Sep 8, 2008 at 2:35 PM, AON LAZIO <aonlazio@gmail .comwrote:
    Hi again pythoners,
    I notice in the class of a code having (object) and (type) attached to
    the name of the class.
    I know that in other cases, that means the class inherits methods and
    properties from other but
    In this case, what does it mean?
    The very same thing. Why should it have a different meaning ?

    For the record :

    - 'object' is the base class for 'new-style' classes - that is, the
    'new' (hem) object model that came with Python 2.2 (released december
    2001 - so it's not that 'new'). The old one - known as 'classic classes'
    has been kept so far for backward compat only, and will finally
    disappear with Python 3.x.

    - 'type' is the base metaclass. Python's classes being objects, they
    have to be instances of a class - known as the metaclass. To avoid
    metametaclasses , metametametacla sses etc ad infinitum, 'type' is an
    instance of itself. And FWIW, a subclass of 'object', which is itself an
    instance of 'type' (usually, brains start melting here...)

    You'll find more informations (and hopefully clearer explanations) here:


    and of course in the FineManual(tm):


    HTH

    Comment

    Working...