Python object() is a built-in function that returns a new featureless that is base for all the classes.

python object() method

Python object() Syntax

object()

object() method doesn’t take any parameters as arguments and it has the methods that are common to all instances of Python classes.

Python object() Function Example

>>> py_obj = object()

Here in above example, we have created a featureless object using object() function and assigned to py_obj.

We can use Python built-in function type() to know the type py_obj.

>>> type(py_obj)
<class 'object'>

As you can clearly see, py_obj belongs to the class object.

Now we will use Python dir() function to list all the attributes of the object returned by object() function.

>>> dir(py_obj)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

Note: object does not have the attribute __dict__, so you can’t assign arbitrary attributes to an instance of the object class.