Tutorial Study Image

Python object()

The built-in function object() returns an empty object. This object is the base for all the classes. It holds the built-in properties and methods which are default. It is not possible to add new properties or methods to this object.


o = object() #where o is the object
 

object() Parameters:

The object() function doesn't accept any parameters.

 

object() Return Value

The object() function returns a featureless object. And this act as a base for all class.

 

Examples of object() method in Python

Example 1: How object() works?


test = object()

print(type(test))
print(dir(test))
 

Output:

test = object()

print(type(test))
print(dir(test))

Example 2: Demonstrating 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
obj1.name = "GeeksforGeeks"
 

Output:

Is obj1 equal to obj2 : False