Skip to main content

object()

The object() function returns a new featureless object without any methods or properties. It is the base prototype object for all Python classes.

Parameter Values

This function does not accept any parameters.

Return Values

The object() function can return an empty, new featureless object which is a base for all classes.

How to Use object() in Python

Example 1:

The object() function returns a new featureless object. The object is a base for all classes. It has the default implementation for all the methods in the object class.

obj = object()
print(type(obj))
# Output: 
Example 2:

The object() function can be used to create an empty class in Python. It is commonly used as the base class in inheritance.

class MyEmptyClass(object):
    pass
Example 3:

The object() function can also be used to create objects in metaprogramming or dynamic class creation scenarios where a simple, featureless object is needed.

def create_object():
    return object()

obj = create_object()
print(obj)
# Output: