summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2023-07-17 03:36:03 (GMT)
committerGitHub <noreply@github.com>2023-07-17 03:36:03 (GMT)
commit7aa89e505d893cd5e6f33b84d66e5fa769089931 (patch)
tree4988c7431865af7fd27eafe1caeb16b63e27c186
parentbabb22da5a25c18a2d203bf72ba35e7861ca60ee (diff)
downloadcpython-7aa89e505d893cd5e6f33b84d66e5fa769089931.zip
cpython-7aa89e505d893cd5e6f33b84d66e5fa769089931.tar.gz
cpython-7aa89e505d893cd5e6f33b84d66e5fa769089931.tar.bz2
gh-106780: Add __match_args__ to tutorial example (#106784)
Add Point definition with this attribute before example that needs it.
-rw-r--r--Doc/tutorial/controlflow.rst8
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 4336bf5..e140f51 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -343,7 +343,13 @@ Dotted names (like ``foo.bar``), attribute names (the ``x=`` and ``y=`` above) o
(recognized by the "(...)" next to them like ``Point`` above) are never assigned to.
Patterns can be arbitrarily nested. For example, if we have a short
-list of points, we could match it like this::
+list of Points, with ``__match_args__`` added, we could match it like this::
+
+ class Point:
+ __match_args__ = ('x', 'y')
+ def __init__(self, x, y):
+ self.x = x
+ self.y = y
match points:
case []: