# __author: "ZXYang"
# date: 2020/12/14
class Test:
# name = 'li'
__slots__ = ['name', 'age', 'sex']
def num(self):
pass
t = Test()
t.name = 'li'
"""
__slots__ = ['name', 'age', 'sex']
限制添加类属性: 'Test' object has no attribute 'height'
会覆盖__dic__属性创建(减少内存开销)
"""
# t.height = '180'
print(t.name)
# print(Test.__dict__)
# print(dir(Test))
"""
{'__module__': '__main__', 'name': 'li', 'num': <function Test.num at 0x000002AA58828438>,
'__dict__': <attribute '__dict__' of 'Test' objects>, '__weakref__': <attribute '__weakref__' of 'Test' objects>,
'__doc__': None}
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
'__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__',
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', '__weakref__', 'name', 'num']
"""