Python object()

This returns a featureless object which is a base for all classes.

The syntax of object():

o = object()

object Parameters

The object() doesn't accept any parameters.

Return Value from object

The object() function returns a featureless object.

Example: How object() works?

test = object()


When you run the program, the output will be:

<class 'object'>
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

Here, an object test of class 'object' is created.

In the program, we used built-in functions type() and dir() to get type and all attributes of the object respectively.

The object doesn't have __dict__ as suggested by the output. Hence, you can't assign arbitrary attributes to the instances of this class.