__slots__ variables and initialization
Holden Caulfield
phoebe_1 at att.net
Wed Jul 31 14:37:53 EDT 2002
Greetings,
I don't recall exactly where I read it, but I had read that ALL the
variables
in __slots__ were initialized to None and are automatically part of
the instance attributes whether they are explicitly created in the
__init__ method or not.
In 2.2.1 this is not what is happening. e.g:
class X(object):
__slots__ = ['_x']
def get_x(self):
return self._x
>>> x = X()
>>> x.get_x()
I get an attribute error. Obviously, defining and '__init__' method
and explicitly creating it works. Is this the way it is supposed to
be?
Also, when is the '__' bug in the '__slots__' variable list going to
be fixed? I am currently embarking on a large project and would like
to nail down the convention of '__' for private variables in a class,
quickly. If the bug fix is going to be further down (2.2.2?) then I
would like to change our convention to something else.
Thanks
More information about the Python-list
mailing list