8000 gh-106780: Add __match_args__ to tutorial example by terryjreedy · Pull Request #106784 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-106780: Add __match_args__ to tutorial example #106784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-106780: Add __match_args__ to tutorial example
Add Point definition with this attribute before example
that needs it.
  • Loading branch information
terryjreedy committed Jul 15, 2023
commit 4fcdfd015f5f4e9d45d6f444b00c0480f8f817fd
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