Skip to content

Commit 6193f78

Browse files
[3.11] gh-106780: Add __match_args__ to tutorial example (GH-106784) (#106820)
Add Point definition with this attribute before example that needs it. (cherry picked from commit 7aa89e5) Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent 9532f0e commit 6193f78

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Doc/tutorial/controlflow.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,13 @@ Dotted names (like ``foo.bar``), attribute names (the ``x=`` and ``y=`` above) o
343343
(recognized by the "(...)" next to them like ``Point`` above) are never assigned to.
344344

345345
Patterns can be arbitrarily nested. For example, if we have a short
346-
list of points, we could match it like this::
346+
list of Points, with ``__match_args__`` added, we could match it like this::
347+
348+
class Point:
349+
__match_args__ = ('x', 'y')
350+
def __init__(self, x, y):
351+
self.x = x
352+
self.y = y
347353

348354
match points:
349355
case []:

0 commit comments

Comments
 (0)