Skip to content

Commit

Permalink
[3.12] Add an example of of custom __repr__ (pythonGH-112761) (pyth…
Browse files Browse the repository at this point in the history
…on#115900)

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

---------

(cherry picked from commit 5770006)

Co-authored-by: Oh seungmin <tmdals179@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
  • Loading branch information
3 people committed Feb 25, 2024
1 parent 59ec6e8 commit 041d85f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,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)

Expand Down

0 comments on commit 041d85f

Please sign in to comment.