Python generally offers two string representations of an object. These are closely aligned with the built-in repr(), str(), and print() functions and the string.format() method:
- Generally, the str() method representation of an object is expected to be more friendly to humans. It is built by an object's __str__() method.
- The repr() method representation is often more technical, and typically uses a complete Python expression to rebuild an object. The documentation for the __repr__() method in the Python documentation (https://docs.python.org/3/reference/datamodel.html?highlight=__del__#object.__repr__) states the following:
"If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment)."
- This is built by an object's...