Python Programming - Objects - Discussion

Discussion Forum : Objects - General Questions (Q.No. 12)
12.
What is the primary purpose of the __str__ method in Python classes?
To create a string representation of the object
To compare objects for equality
To initialize the object's attributes
To perform object serialization
Answer: Option
Explanation:
The __str__ method is used to define the string representation of an object. It is automatically called when the str() function is invoked on the object.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.