python – 可以在__slots__类中定义__setattr __()吗?

假设我有一个定义__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 ==

返回顶部