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 Randomly Select an Element From the List
Python exec()
Python Dictionary fromkeys()
Python String zfill()
Python dir()
Python String find()
Python Program to Sort a Dictionary by Value
Python Dictionary setdefault()
Python List remove()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python Program to Parse a String to a Float or Int
Python String isalpha()
Python Objects and Classes
Python range()
Python Set add()
Python Dictionary popitem()
Python Program to Check Leap Year
Python Dictionary values()
Python String format()
Python sum()
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Python bool()
Python List count()
Python Variables, Constants and Literals
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Program to Convert String to Datetime
Python enumerate()
Python Program to Convert Celsius To Fahrenheit
Python setattr()
Python Program to Iterate Over Dictionaries Using for Loop
Python Program to Check If a List is Empty