repr(object)
Returns the formal string representation of a specified object.
Parameters
The repr() function takes one parameter:
obj: The object for which you want a formal string representation. For many types, the function returns a string that, when passed toeval(), can produce an object with the same value as the original.
In other cases, the representation is a string enclosed in angle brackets < >, containing the type name and additional information, often the object’s name and its memory address.
Return Value
- The
repr()function returns the formal string representation of the specified object.
Examples
class Animal:
pass
repr(Animal()) # <__main__.Animal object at 0x...>
repr('cat-кот') # 'cat-кот'