__slots__

Ulrich Petri ulope at gmx.de
Sat Nov 8 13:29:54 CET 2003


"flori" <fgrimm at inneo.de> schrieb im Newsbeitrag
news:9d5f9ae4.0311070836.7503de86 at posting.google.com...
> i try to greate somthing like this
>
> class ca(object): __slots__ = ("a",)
> class cb(ca): __slots__ = ("a","b")
> class cc(ca): __slots__ = ("a","c")
> class cd(cb,cc): __slots__ = ("a","b","c","d")
>
> but i didn't find a simple solution
> so i'm using a metaclass that generate a __slots__-free and a
> __slots__-version
> the __slots__ -free is returned
> the __new__ of the base class look for the sloted verion
> the classes defines a (class)-attribute __object_slots__ with their
> new attribute names.
>
> killer? someone a good idea?
>
> my soure (something not important i'm cutting away)
>

<snip lots of code that looks like java in python>

What exactly are you trying to accomplish?

Ciao Ulrich






More information about the Python-list mailing list