Even after seeing what the repr function does, it can be hard to put into words an explanation of the behavior. Here are some examples.


repr() function

a = 'False'
b = False
c = 'test\ting'
d = 2.356e-4
print a
print b
print type(a), type(b)
print repr(a)
print repr(b)
print c
print repr(c)
print d
print repr(d)


As can be seen in the output, the main thing that repr allows us to do is to get around the fact that "print" in Python normally inteprets what is in a string. To print what a programmer imagines is the real content of a string, use repr.