Skip to content

Commit 7aa89e5

Browse files
authored
gh-106780: Add __match_args__ to tutorial example (#106784)
Add Point definition with this attribute before example that needs it.
1 parent babb22d commit 7aa89e5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Doc/tutorial/controlflow.rst

+7-1
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)