Python: __str__( ) vs. __repr__( )
See the original posting on DZone Python
Every time I find myself in front of an ambiguity in Python, the official documentation is there for me. It is very well written and, trust me, very explicit. So, let us start by discovering what it has to say about this subject.
According to the official documentation,
__repr__() is used to compute an official string representation of an object which, and, if possible, can be used to recreate the object itself, however,
__str__() is used to compute an informal string representation of that object.