repr function attempts to convert any
value to a string. Unlike the
it attempts to display the value in Python source form, that
is, in a form suitable for passing to
(see Section 21.6, “
eval(): Evaluate an expression in source
form”). It works the same as
`...` operator. Examples:
>>> s='Wensleydale' >>> print s Wensleydale >>> print str(s) Wensleydale >>> print repr(s) 'Wensleydale' >>> print `s` 'Wensleydale'
To specify the behavior of the
it is applied to an instance of a user-defined class, see
Section 26.3.19, “
__repr__(): String representation”.