The object() function returns a featureless object which is a base for all classes.
The syntax of object() is:
o = object()
1. object() Parameters
The object() function doesn’t accept any parameters.
2. Return Value from object()
The object() function returns a featureless object.
3. Example: How object() works?
test = object() print(type(test)) print(dir(test))
Output
<class 'object'> ['__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__']
Here, an object test is created.
In the program, we have used type() to get the type of the object.
Similarly, we have used dir() to get all the attributes. These attributes (properties and methods) are common to instances of all Python classes.
Related posts:
Python Input, Output and Import
Python String format()
Python Program to Differentiate Between del, remove, and pop on a List
Python List
Python *args and **kwargs
Python String rstrip()
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python timestamp to datetime and vice-versa
Python Set remove()
Python String rpartition()
Python Program to Parse a String to a Float or Int
Python Object Oriented Programming
Python Program to Merge Two Dictionaries
Python Set discard()
Python Set issubset()
Python Program to Compute the Power of a Number
Python Program to Illustrate Different Set Operations
Python List sort()
Python Program to Find All File with .txt Extension Present Inside a Directory
Python String ljust()
Python Program to Create Pyramid Patterns
Python Program to Find LCM
Python Program to Remove Punctuations From a String
Python Variables, Constants and Literals
Python String lstrip()
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python Program to Find HCF or GCD
Python List pop()
Python Set union()
Python getattr()
Python Program to Generate a Random Number
Python Program to Convert Kilometers to Miles