__slots__ and metaclasses

Robert Ferrell ferrell at diablotech.com
Fri Nov 15 14:54:40 EST 2002


Alex Martelli <aleax at aleax.it> wrote in message news:<NyTA9.13660$Yw.563200 at news2.tin.it>...
> Robert Ferrell wrote:
> 
> > How can I set the __slots__ attribute for a class in the classes
> > metaclass?  I tried adding:
> > 
> >     setattr(cls, '__slots__', __slots__)
> > 
> > to the __init__ method in the metaclass, but that did not work.  Is
> > what I'm trying to do even possible?  I've read what I could find
> > about metaclasses and __slots__, and I've mostly got the metaclasses
> > working for me.  But I'm stuck on this one point.  Any help/pointers
> 
> See, for example:
> 
> http://groups.google.com/groups?hl=en&selm=0qZV8.51942%24vm5.1927874%40news2.tin.it
> 

Thanks for the pointer.  That did the trick, and it even works for me!
 Sweet.

So much more for me to learn about the meaning of "__" prefix, what
goes on in __new__ vs. __init__, etc...

-robert



More information about the Python-list mailing list