Python built-in functions (45) -- object, pythonobject
English document:
Class object
Return a new featureless object. object is a base for all classes. It has the methods that are common to all instances of Python classes. This function does not accept any arguments.
Note: object does not have a _ dict __, so you can't assign arbitrary attributes to an instance of the object class.
Note:
1. The object class is the base class of all classes in Python. If no class is specified to be inherited when defining a class, the object class is inherited by default.
>>> class A: pass>>> issubclass(A,object)True
2. The object class defines some common methods of 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__']
3. The object class does not define _ dict __, so you cannot set the attribute value for the object class instance object.
>>> A = object () >>>. name = 'Kim '# attributes Traceback (most recent call last) cannot be set: File "<pyshell #9>", line 1, in <module>. name = 'Kim 'AttributeError: 'object' object has no attribute 'name' # define A class A >>> class: pass >>> a = A () >>>>>. name = 'Kim '# attributes can be set