https://github.com/python/cpython/commit/c0789209c49167d563b5777966b40dca7f6411fb
commit: c0789209c49167d563b5777966b40dca7f6411fb
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy <[email protected]>
date: 2024-02-25T08:06:37Z
summary:

[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 5770006ffac2abd4f1c9fd33bf5015c9ef023576)

Co-authored-by: Oh seungmin <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>

files:
M Doc/library/functions.rst

diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 1db28060795442..086b3a3bee579c 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -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)
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to