Python: Differences between str() vs repr()
Both str() and repr() are used to represent strings in python.
But, there exists some differences in their representation.
str() return strings which ease human-reading.
repr() return string which can also the read by human-beings,
but its representation eases the machine.
Observe few differences below:
They differ in displaying the string
>>> s='Hello, world!!!!'
Though both are representing the same string, they are not logically same.
But, str(repr()) and repr(str()), both are finally equal
Note the number of digits after decimal point, being represented for floating-point values,by both of them.
Observe the presence and absence of effect of escape sequences, in printing a str() and repr() based strings, respectively.
>>> print str(s)
>>> print repr(s)