inheriting type or object?

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

    #1

    inheriting type or object?

    Hi folks!

    As stated in subject, how do I decide wether to inherit <type 'type'> or
    <type 'object'>? Whenever I want to intantiate my derived type, I taked
    <type 'type'> here, but inheriting from <type 'object'> consequently would
    be reasonable in cases of pure static objects (i.e. objects/types using
    staticmethods exclusively), for whose I would prefer toplevel code outside
    a class definition in python, since python does not oblige programmers to
    use classes (like JAVA et. al.).

    So, finally, my question is: Is there a design pattern, that makes
    <type 'object'> a reasonable (direct) base type for new objects/types?
    Right now, I can't see any.

    Thank you for answering!
    Greetings,
    F. Sidler
  • James Stroud

    #2
    Re: inheriting type or object?

    Fabiano Sidler wrote:[color=blue]
    > Hi folks!
    >
    > As stated in subject, how do I decide wether to inherit <type 'type'> or
    > <type 'object'>? Whenever I want to intantiate my derived type, I taked
    > <type 'type'> here, but inheriting from <type 'object'> consequently would
    > be reasonable in cases of pure static objects (i.e. objects/types using
    > staticmethods exclusively), for whose I would prefer toplevel code outside
    > a class definition in python, since python does not oblige programmers to
    > use classes (like JAVA et. al.).
    >
    > So, finally, my question is: Is there a design pattern, that makes
    > <type 'object'> a reasonable (direct) base type for new objects/types?
    > Right now, I can't see any.
    >
    > Thank you for answering!
    > Greetings,
    > F. Sidler[/color]

    I don't think these are the recommended usages for type and object.
    Usually class factories (metaclasses) inheret from type and classes that
    instantiate objects inheret from object. I think this might clear up the
    issue:



    James

    --
    James Stroud
    UCLA-DOE Institute for Genomics and Proteomics
    Box 951570
    Los Angeles, CA 90095


    Comment

    Working...