inheriting type or object?

James Stroud jstroud at ucla.edu
Thu Apr 27 18:09:22 EDT 2006


Fabiano Sidler wrote:
> 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/



More information about the Python-list mailing list