]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106780: Add __match_args__ to tutorial example (#106784)
authorTerry Jan Reedy <tjreedy@udel.edu>
Mon, 17 Jul 2023 03:36:03 +0000 (23:36 -0400)
committerGitHub <noreply@github.com>
Mon, 17 Jul 2023 03:36:03 +0000 (23:36 -0400)
Add Point definition with this attribute before example
that needs it.

Doc/tutorial/controlflow.rst

index 4336bf50df40a73871217f3cb2d6c7409fc2d0cc..e140f51f1dda7815189bb5fc52d5fb11c0402a02 100644 (file)
@@ -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 []: