structs in python
Alex Martelli
aleax at aleax.it
Sun Jul 7 11:24:44 EDT 2002
Opus wrote:
> And the __slots__ way is strange if you are using the __variables in your
> class.
>
> class thing(object):
> __slots__ = ["_thing__var"] # Huh???
> def __init__(self,init):
> self.__var = init
This is a bug in Python 2.2, already fixed in the Python 2.3 pre-alpha
that's currently in the CVS tree -- now, type.__new__ properly 'decorates'
(aka 'mangles') each slotname whose name starts with '__' (and does not
end with '__') so __slots__=['__var'] will work fine here. Hopefully
this bug fix will be backported to 2.2.2 ...
Alex
More information about the Python-list
mailing list