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 round()
Python Closures
Deep Learning with Python - Francois Cholletf
Python Program to Transpose a Matrix
Python Program to Count the Occurrence of an Item in a List
Python List sort()
How to get current date and time in Python?
Python break and continue
Python Program to Merge Two Dictionaries
Python Global Keyword
Python Program to Sort Words in Alphabetic Order
Python String isnumeric()
Python Program to Convert Two Lists Into a Dictionary
Python String isprintable()
Python Program to Get File Creation and Modification Date
Python Program to Solve Quadratic Equation
Python Program to Create Pyramid Patterns
Python float()
Python callable()
Python String lstrip()
Python Dictionary values()
Python Program to Find Factorial of Number Using Recursion
Python String isspace()
Python Program to Sort a Dictionary by Value
Python String translate()
Python Program to Add Two Numbers
Python String capitalize()
Python Program to Shuffle Deck of Cards
Python eval()
Python List clear()
Python Set update()
Python Program to Capitalize the First Character of a String