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 Program to Reverse a Number
Python Custom Exceptions
Python Program to Extract Extension From the File Name
Python Exception Handling Using try, except and finally statement
Python Program to Display Calendar
Python String islower()
Python Tuple count()
Python Machine Learning Third Edition - Sebastian Raschka & Vahid Mirjalili
Python Matrices and NumPy Arrays
Intelligent Projects Using Python - Santanu Pattanayak
Python Data Types
Python input()
Python strptime()
Python divmod()
Python List pop()
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python dict()
Python List
Python Sets
Python map()
Deep Learning with Python - Francois Cholletf
Python Closures
Python Set intersection_update()
Python hex()
Python Program to Convert String to Datetime
Python Program to Compute the Power of a Number
Python timestamp to datetime and vice-versa
Python Dictionary values()
Python Program to Print all Prime Numbers in an Interval
Python reversed()
Python Program to Count the Number of Occurrence of a Character in String
Python String partition()