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:
parent
c69a1c37b5
commit
2eaa17b707
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue