Python object Function with Examples

The Python function object generates an instance of an empty object. This serves as the foundational element for all classes and contains the inherent properties and methods that are standard for every class.

Python object Function Syntax

It has the following syntax:

Example

object()

Return

It returns an empty object.

Python object Function Example

The example provided below demonstrates how the object function operates in Python.

Example

python = object()

print(type(python))

print(dir(python))

Output:

Output

<class 'object'>

['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',

'__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__',

'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',

'__str__', '__subclasshook__']

Explanation:

In the preceding illustration, an instance of the 'object' class is instantiated. We utilized the built-in functions referred to as type and dir to determine the type and to list all the attributes associated with the object, respectively. As indicated by the output, the object lacks a dict attribute. Consequently, it is not possible to assign arbitrary attributes to the instances of this particular class.

Input Required

This code uses input(). Please provide values below: