Make default superclass 'object' if not specified?

Jp Calderone exarkun at intarweb.us
Mon Jun 9 22:20:11 EDT 2003


On Tue, Jun 10, 2003 at 01:01:38AM +0000, Robert Oschler wrote:
> I just had an incident where I was puzzled over __slots__.  I had defined
> __slots__ for a new class definition I created, yet instances of the class
> were accepting assignments to attributes not in the __slots__ list.  I had
> forgotten to derive the new class from 'object'.  Is there a way to make the
> default superclass for all defined classes 'object' if none is specified?
> 

  Put "__metaclass__ = type" at the top of your module.  As far as I know,
this can only be done on a per-module basis and in this way.

  Jp

-- 
A sad spectacle.  If they be inhabited, what a scope for misery 
and folly.  If they be not inhabited, what a waste of space.
                -- Thomas Carlyle, looking at the stars





More information about the Python-list mailing list