Python3.x的内置类属性

> python --version
Python 3.7.1
In [1]: class People(object):
   ...:     pass
   ...:

In [2]: dir(People)
Out[2]:
['__class__',			# 实例所在的类
 '__delattr__',			# 删除name属性
 '__dict__',			# 实例自定义属性
 '__dir__',
 '__doc__',				# 类文档,子类不继承
 '__eq__',				# 判断self对象是否等于other对象
 '__format__',
 '__ge__',				# 判断self对象是否大于或者等于other对象
 '__getattribute__',	# 属性访问拦截器
 '__gt__',				# 判断self对象是否大于other对象
 '__hash__',
 '__init__',			# 构造初始化函数
 '__init_subclass__',
 '__le__',				# 判断self对象是否小于或者等于other对象
 '__lt__',				# 判断self对象是否小于other对象
 '__module__',
 '__ne__',
 '__new__',				# 生成实例所需属性
 '__reduce__',
 '__reduce_ex__',
 '__repr__',			# 实例字符串表示,准确性
 '__setattr__',			# 设置name属性
 '__sizeof__',
 '__str__',				# 实例字符串表示,可读性
 '__subclasshook__',
 '__weakref__']

In [3]:

另外:

__del__ 析构
__call__(self,*args) 把实例对象作为函数调用


参考:
Python 内置类属性 https://www.cnblogs.com/yangliguo/p/8178135.html

原文地址:https://www.cnblogs.com/onefine/p/10499333.html