On this page
  1. repr
  2. Import & Availability
  3. Overview & Signature
  4. Usage
  5. Gotchas
  6. REPL Inspect

repr

Prev: range | Up: __builtins__ | Next: reversed
Rel: callable, delattr, dir, getattr, hasattr
Ref: docs.python.org — repr
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import repr

Overview & Signature

repr(obj, /)

Return the canonical string representation of the object.

Usage

assert repr("hi\n") == "'hi\\n'"
assert str("hi\n") == "hi\n"

Gotchas

REPL Inspect

help(repr)

Linked from

Related notes