を定義するクラスがあるとします__slots__:
class Foo(object):
__slots__ = ['x']
def __init__(self, x=1):
self.x = x
# will the following work?
def __setattr__(self, key, value):
if key == 'x':
object.__setattr__(self, name, -value) # Haha - let's set to minus x
それを定義できます__setattr__()か?
Fooがないので、__dict__何を更新しますか?