Skip to content

Commit

Permalink
[3.11] gh-106780: Add __match_args__ to tutorial example (GH-106784) (#…
Browse files Browse the repository at this point in the history
…106820)

Add Point definition with this attribute before example
that needs it.
(cherry picked from commit 7aa89e5)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
  • Loading branch information
miss-islington and terryjreedy authored Jul 17, 2023
1 parent 9532f0e commit 6193f78
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Doc/tutorial/controlflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 []:
Expand Down

0 comments on commit 6193f78

Please sign in to comment.