Friday, September 30, 2011

__slots__ cannot be updated

>>> class Slots(object):  __slots__ = ()
...
>>> Slots.__slots__ = ('t',)
>>> Slots.__slots__
('t',)
>>> s2 = Slots()
>>> s2.t = 5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Slots' object has no attribute 't'

1 comment:

  1. The best way to satisfy simultaneously the thirst for travel, secrets and treasures is to play the automaton https://bookofras.com/.

    ReplyDelete