Name
__str__
Synopsis
__str__(self)
The
str(
x
)
built-in type and the print
x
statement call
x
.__str__( )
to
obtain an informal, concise string representation of
x
. If __str__
is
absent, Python calls x
.__repr__
instead. __str__
should return a
conveniently human-readable string, even if it entails some
approximation.
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.