What does the following code print in the interpreter ?
>>> class Sample(): ... def __repr__(self): ... return '__repr__ is called' ... def __str__(self): ... return '__str__ is called' ... >>> p = Sample() >>> print(p)
__str__ is called
__repr__ is called
<class 'object'>
<class '__main__.Sample'>
When an object is used in print() , it invokes __str__() method
Comment here: