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 Get Current time
Python String format()
Python Program to Check if a Key is Already Present in a Dictionary
Python slice()
Python Program to Get the Last Element of the List
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Object Oriented Programming
Python Program to Find Hash of File
Python Program to Access Index of a List Using for Loop
Python for Loop
Python Program to Shuffle Deck of Cards
Python Program to Iterate Through Two Lists in Parallel
Python Global Keyword
Python String istitle()
Python Program to Compute all the Permutation of the String
Python List index()
Python String capitalize()
Intelligent Projects Using Python - Santanu Pattanayak
Python Program to Copy a File
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Numbers, Type Conversion and Mathematics
Python reversed()
Python timestamp to datetime and vice-versa
Python Dictionary keys()
Python divmod()
Python Machine Learning Eqution Reference - Sebastian Raschka
Python Program to Split a List Into Evenly Sized Chunks
Python Program to Get a Substring of a String
Python Program to Convert String to Datetime
Python Program to Find All File with .txt Extension Present Inside a Directory
Python String ljust()
Python open()