你的问题在里面有答案
Usage of __slots__?
Requirements:
To have attributes named in __slots__ to actually be
stored in slots instead of a __dict__, a class must
inherit from object.
To prevent the creation of a __dict__, you must
inherit from object and all classes in the inheritance
must declare __slots__ and none of them can
have a '__dict__' entry.
尤其是,你必须有一个完整的
__slots__
从最初的
object
继承到当前类,否则您将拥有
__dict__
可用,插槽将无法阻止修改。
对象不使用槽,所以不能使用它的子类来阻止设置属性