This is from the Python docs. I don't understand this, can someone give some examples?
If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). This renders the meaning of the program undefined. In the future, a check may be added to prevent this.
I tried to make an example of this but failed. When I run the program below it prints 1
, so the variable is not inaccessible. When would it be?
class Base(object):
__slots__ = 'a'
def __init__(self):
self.a = 1
class Subclass(Base):
__slots__ = 'a'
def __init__(self):
super(Subclass, self).__init__()
print self.a
Subclass()