- 2025年05月12日
- 星期一
假设我有一个定义__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 ==
假设我有一个定义__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 ==