__str__()

>>> class Test:
...     def __repr__(self):
...         return "Test()"
...     def __str__(self):
...         return "member of Test"
... 
>>> t = Test()
>>> t
Test()
>>> print(t)
member of Test

Here is what the above code is Doing:
1. We create a class named Test.
2. We define a __repr__() method that returns a string representation of the object.
3. We define a __str__() method that returns a string representation of the object.
4. We create an instance of the class named t.
5. We print the instance t.

The __repr__() method is called when we print the object t. The __str__() method is called when we convert the object t to a string.

The __repr__() method is used to compute the “official” string representation of an object. This is the string that would be used to recreate the object.

The __str__() method is used to compute the “informal” string representation of an object. This is the string that would be used to display the object.

The __repr__() method is defined in the object’s class. The __str__() method is defined in the object’s class.

The __repr__() method is called when the repr() function is invoked on the object. The __str__() method is called when the str() function is invoked on the object.

The __repr__() method is called when the print() function is invoked on the object. The __str__() method is called when the print() function is invoked on the object.

The __repr__() method is called when the format() function is invoked on the object. The __str__() method is called when the format() function is invoked on the object.

The __repr__() method is called when the input() function is invoked on the object. The __str__() method is called when the input() function is invoked on the object.

The __repr__() method is called when the eval() function is invoked on the object. The __str__() method is called when the eval() function is invoked on the object.

The __repr__() method is called when the chr() function is invoked on the object. The __str__() method is called when the chr() function is invoked on the object.

The __repr__() method is called when the ord() function is invoked on the object. The __str__() method is called when the ord() function is invoked on the object.

The __repr__() method is called when the bin() function is invoked on the object. The __str__() method is called when the bin() function is invoked on the object.

The __repr__() method is called when the hex() function is invoked on the object. The __str__() method is called when the hex() function is invoked on the object.

The __repr__() method is called when the oct() function is invoked on the object. The __str__() method is called when the oct() function is invoked on the object.