Код: Выделить всё
class MyClass( object ) :
m = None # my attribute
__slots__ = ( "m" ) # ensure that object has no _m etc
a = MyClass() # create one
a.m = "?" # here is a PROBLEM
Код: Выделить всё
Traceback (most recent call last):
File "test.py", line 8, in
a.m = "?"
AttributeError: 'test' object attribute 'm' is read-only
Подробнее здесь: https://stackoverflow.com/questions/820 ... -read-only
Мобильная версия