Skip to content

Commit

Permalink
PEP 636: clarify __match_args__ naming (#2136)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jsaponara and gvanrossum authored Nov 8, 2021
1 parent c69a1c3 commit 2eaa17b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pep-0636.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2eaa17b

Please sign in to comment.