python __slots__

# 限制实例的属性?比如,只允许对Student实例添加nameage属性。

class Student(object):
    __slots__ = ('name', 'age') # 用tuple定义允许绑定的属性名称
原文地址:https://www.cnblogs.com/root0/p/15294472.html