repr()
Built-in FunctionPython 2.0+Intermediate
Returns a developer-friendly string representation of an object
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
print(repr("hello")) print(repr(42)) print(repr([1, 2, 3]))
repr() is a built-in function that returns a developer-friendly string representation of an object.
Try in PlaygroundTags
builtinfunctioncorestringdebuggingintrospection
Related Items
str()
Built-in Function
Converts a value to a string
__repr__
Dunder Method
Returns an unambiguous developer-facing string representation
__str__
Dunder Method
Returns a human-readable string representation (used by print and str())
format()
Built-in Function
Formats a value according to a format specification string
pprint
Stdlib — Data
Pretty-printer for data structures