Python object() function

The object() function in Python returns an empty object, which is the base for all classes. For example:

x = object()

The output will be:

<class 'object'>

Python's object() function returns a new object with no methods or attributes other than those inherited from the object class.

object() is the base class for all Python classes. This implies that every Python class is a subclass of object().

object() provides no particular functionality or behavior. It is intended to serve as a basis for defining new classes.

Since object() has no attributes or methods, its memory usage is minimal. This makes it an efficient choice when a large number of class instances must be created.

object() is compatible with all Python versions, so it can be used in any Python project without compatibility concerns.

When you subclass object(), you can add your own attributes and methods to create a class that meets your particular requirements.

object() is not intended for standalone use. It is only useful when subclassed and customized by the user.

You can specify the base class when creating a new class in Python by including it in the class definition. If no base class is specified, Python will use object() as the default base class.

Syntax of Python object()

Python's object() function syntax is as follows:


The function object() does not take any arguments. It returns a featureless object.

Example of Python object() Function

Here is an example of the object() function in Python. This program uses the dir() function to print all the default properties and methods for all the classes:

x = object()
xpm = dir(x)
for x in xpm:

This program's sample output, which shows how the Python object() function works, is shown in the picture below:

python object function

Advantages of the object() function in Python

Disadvantages of the object() function in Python

Python Online Test

« Previous Function Next Function »

Liked this article? Share it!

Like/follow us on social media for updates!