Dictless classes

Roy Smith roy at panix.com
Tue Jul 3 08:28:01 EDT 2012


In article <XnsA0856B054AB3Fduncanbooth at 127.0.0.1>,
 Duncan Booth <duncan.booth at invalid.invalid> wrote:

> Also you cannot create a subclass of 'type' with non-empty slots (it throws 
> a type error "nonempty __slots__ not supported for subtype of 'type'"). 
> However I don't think that's really relevant as even if they did allow you 
> to use __slots__ it wouldn't prevent the creation of a __dict__ for the 
> 'type' base class.

I played around a bit trying to write a metaclass which implemented:

def __getattribute__(self, name):
   if name == "__dict__":
      raise AttributeError

but didn't get very far.  Maybe somebody with stronger metaclass-fu than 
I have could run with this idea?



More information about the Python-list mailing list