[3.11] Add an example of of custom __repr__ (GH-112761) (#115901)

Added to repr entry in Doc/library/functions.rst.

---------

(cherry picked from commit 5770006ffa)

Co-authored-by: Oh seungmin <tmdals179@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Miss Islington (bot) 2024-02-25 09:06:37 +01:00 committed by GitHub
parent 92e43aea35
commit c0789209c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1568,6 +1568,16 @@ are always available. They are listed here in alphabetical order.
If :func:`sys.displayhook` is not accessible, this function will raise
:exc:`RuntimeError`.
This class has a custom representation that can be evaluated::
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def __repr__(self):
return f"Person('{self.name}', {self.age})"
.. function:: reversed(seq)