__slots__ and private data members

Jeremy Lowery jslowery at hotmail.com
Thu Aug 22 05:34:47 CEST 2002


Cancel that, I see someone beat me too it.

J

> Is this a bug? If not, is there a way to work around it or some rationale
> behind it?
>
> >>> class Death(object):
> ...     __slots__ = ('__name', )
> ...     def __init__(self, name):
> ...            self.__name = name
> ...
> >>> d = Death('spam')
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File "<interactive input>", line 4, in __init__
> AttributeError: 'Death' object has no attribute '_Death__name'
> >>>
>
>
>
>
>






More information about the Python-list mailing list