Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python object() method

  • Last Updated : 22 Sep, 2021

Python object() function returns the empty object, and the Python object takes no parameters.

In python, each variable to which we assign a value/container is treated as an object. Object in itself is a class. Let’s discuss the properties and demonstration of how this class can be utilized for day-day programming.

Syntax : object()

Parameters :  None

Returns : Object of featureless class. Acts as base for all object

Example 1: Demonstrating working of object()


# Python 3 code to demonstrate
# working of object()
# declaring the object of class object
obj = object()
# printing its type
print("The type of object class object is : ")
# printing its attributes
print("The attributes of its class are : ")


The type of object class object is : 
The attributes of its class are : 
[‘__class__’, ‘__delattr__’, ‘__dir__’, ‘__doc__’, ‘__eq__’, ‘__format__’, ‘__ge__’, ‘__getattribute__’, ‘__gt__’, ‘__hash__’, ‘__init__’, ‘__le__’, ‘__lt__’, ‘__ne__’, ‘__new__’, ‘__reduce__’, ‘__reduce_ex__’, ‘__repr__’, ‘__setattr__’, ‘__sizeof__’, ‘__str__’, ‘__subclasshook__’]

Properties of object()

  • Objects of object class cannot add new attributes to it.
  • These objects are uniquely made and do not equate to one other, i.e don’t return true once compared.
  • the object acts as a base class for all the custom objects that we make.

Example 2 : Demonstrating properties of object() 


# Python 3 code to demonstrate
# properties of object()
# declaring the objects of class object
obj1 = object()
obj2 = object()
# checking for object equality
print("Is obj1 equal to obj2 : " + str(obj1 == obj2))
# trying to add attribute to object = "GeeksforGeeks"


Is obj1 equal to obj2 : False


Traceback (most recent call last):
  File "/home/", line 12, in = "GeeksforGeeks"
AttributeError: 'object' object has no attribute 'name'

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!