Python object() Function

Python 内置函数Python Built-in Functions


Description

object()The function returns an empty object, and we cannot add new properties or methods to this object.

object()The object returned by the function is the base class of all classes. It has no properties or methods, only some special properties and methods common to Python built-in objects, such as __doc__, __class__, __delattr__, __getattribute__, etc.

object()It is the most basic object in Python, and all other objects are derived from it. Therefore, the object() object is the topmost superclass (also called base class or parent class) of all Python classes. All built-in types, user-defined classes, and any other types directly or indirectly inherit from it.

Syntax

id Syntax:

object()

Parameter description:

  • None.

Return Value

Returns an empty object.

Example

The following example creates an empty object:

x = object() print(dir(x))

The output of the above example is:

['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

Python 内置函数Python Built-in Functions

Other Extensions