Name
__repr__
Synopsis
__repr__(self)
The
repr(
x
)
built-in function call, the `x`
expression form,
and the interactive interpreter (when x
is
the result of an expression statement) call
x
.__repr__( )
to
obtain an official, complete string representation of
x
. If __repr__
is
absent, Python uses a default string representation. __repr__
should return a string with unambiguous
information on x
. Ideally, when feasible,
the string should be an expression such that
eval(repr(
x
))==
x
.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.