Python Object() function

Published February 16, 2022

The object() function is a Python built-in function that returns an empty object, which is the base of all classes. Objects returned by this method are unique and cannot be modified in any way.

Syntax
The syntax of the object() is:

Object()

If this function doesn't have any parameters, then the object will return an empty object.
Lets see how this function works in the example below


Example

x = object()
print("The cfeated class is : ")
print(type(x))
print("The attributes includes : ")
print(dir(x))


Output
The above code returns an empty object

The cfeated class is :
<class 'object'>
The attributes includes :
['__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__']

 

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

369 Views