PEP 636: clarify __match_args__ naming (#2136)

* clarify __match_args__ naming

The current example allows the reader to wonder whether the __match_args__ names must match the __init__ args or the class members.  This change explicitly shows that class member names are searched for the __match_args__ items (admittedly at the cost of some clutter).

* Update pep-0636.rst

Thx Guido, that reduces the clutter.

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>

* oops, thx again!

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
This commit is contained in:
John Saponara 2021-11-07 23:12:11 -05:00 committed by GitHub
parent c69a1c37b5
commit 2eaa17b707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -359,7 +359,9 @@ this alternative definition::
class Click:
__match_args__ = ("position", "button")
def __init__(self, position, button):
def __init__(self, pos, btn):
self.position = pos
self.button = btn
...
The ``__match_args__`` special attribute defines an explicit order for your attributes