The reprt
function is used to obtain a canonical string
representation of the object. Backticks (also called conversion or reverse quotes) do
the same thing. Note that you will have eval(repr(object)) == object
most of the time.
>>> i = [] >>> i.append('item') >>> `i` "['item']" >>> repr(i) "['item']"
Basically, the repr
function or the backticks are used to obtain
a printable representation of the object. you can control what your objects return
for the repr
function by defining the __repr__
method in your class.