English documents
Class object
Return a new featureless object. object is a base for all classes. It has the methods is common to all instances of Python classes. This function does the not accept any arguments.
Note:object does not has a __dict__, so can ' t assign arbitrary attributes to an instance of the object class.
Description
The object class is the base class for all classes in Python, and if you define a class that does not specify inheriting that class, the object class is inherited by default
>>> class A: pass>>> issubclass (a,object) True
The object class defines some common methods for all classes
>>> Dir (object) [' __class__ ', ' __delattr__ ', ' __dir__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' __ge__ ', ' __ getattribute__ ', ' __gt__ ', ' __hash__ ', ' __init__ ', ' __le__ ', ' __lt__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex_ _ ', ' __repr__ ', ' __setattr__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ']
Object does not have a __dict__ defined, so you cannot attempt to set properties on object class instance objects
>>> A = object () >>> a.name = ' Kim ' # Cannot set property Traceback (most recent call last): File "<pyshell#9> ; ", line 1, in <module> a.name = ' Kim ' attributeerror: ' Object ' object has no attribute ' name ' #定义一个类A >>> Class A: pass>>> a = A () >>> >>> a.name = ' Kim ' # can set properties
Zhuanzai
Python built-in function object