inheriting type or object?

F

Fabiano Sidler

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
 
J

James Stroud

Fabiano said:
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

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:

http://www.python.org/download/releases/2.2/descrintro/

James

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

http://www.jamesstroud.com/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top