Next / Previous / Contents / TCC Help System / NM Tech homepage

14.17. repr(): Representation

The repr function attempts to convert any value to a string. Unlike the str() function, it attempts to display the value in Python source form, that is, in a form suitable for passing to eval() (see Section 14.6, “eval(): Evaluate an expression in source form”). It works the same as the `...` operator. Examples:

>>> s='Wensleydale'
>>> print s
Wensleydale
>>> print str(s)
Wensleydale
>>> print repr(s)
'Wensleydale'
>>> print `s`
'Wensleydale'