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 File I/O Operation
Python String index()
Python Program to Display Calendar
Python Program to Find the Square Root
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python chr()
Python Functions
Python Machine Learning Third Edition - Sebastian Raschka & Vahid Mirjalili
Python Program to Create Pyramid Patterns
Python oct()
Python Program to Check if a Key is Already Present in a Dictionary
Python String splitlines()
Python Program to Find the Largest Among Three Numbers
Python Program to Differentiate Between del, remove, and pop on a List
Python Program to Delete an Element From a Dictionary
Python List Comprehension
Python Directory and Files Management
Python Program to Represent enum
Python Program to Reverse a Number
Python Program to Get a Substring of a String
Python String casefold()
Python List index()
Python String lstrip()
Python List clear()
Python bytearray()
Python Set remove()
Python Set add()
Python Program to Add Two Matrices
Python dict()
Python pass statement
Python String rindex()
Python String isdecimal()