[Python-checkins] [3.12] gh-106780: Add __match_args__ to tutorial example (GH-106784) (#106819)
terryjreedy
webhook-mailer at python.org
Mon Jul 17 04:15:39 EDT 2023
https://github.com/python/cpython/commit/11b3d38310e98d1fc079938c0ec1b3992a0c7c03
commit: 11b3d38310e98d1fc079938c0ec1b3992a0c7c03
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: terryjreedy <tjreedy at udel.edu>
date: 2023-07-17T04:15:35-04:00
summary:
[3.12] gh-106780: Add __match_args__ to tutorial example (GH-106784) (#106819)
Add Point definition with this attribute before example
that needs it.
(cherry picked from commit 7aa89e505d893cd5e6f33b84d66e5fa769089931)
Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>
files:
M Doc/tutorial/controlflow.rst
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 4336bf50df40a..e140f51f1dda7 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 []:
More information about the Python-checkins
mailing list