From 31d148c9f854dd3f52bfcf0750640bcd44163f83 Mon Sep 17 00:00:00 2001 From: John Saponara Date: Sun, 7 Nov 2021 08:40:12 -0500 Subject: [PATCH 1/3] 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). --- pep-0636.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pep-0636.rst b/pep-0636.rst index 144aab6fad5..4ea41308f76 100644 --- a/pep-0636.rst +++ b/pep-0636.rst @@ -359,7 +359,9 @@ this alternative definition:: class Click: __match_args__ = ("position", "button") - def __init__(self, position, button): + def __init__(self, position_arg, button_arg): + self.position = position_arg + self.button = button_arg ... The ``__match_args__`` special attribute defines an explicit order for your attributes From 44604494b3bedb154bc3edf619e30cab6f5ce6a7 Mon Sep 17 00:00:00 2001 From: John Saponara Date: Sun, 7 Nov 2021 19:13:43 -0500 Subject: [PATCH 2/3] Update pep-0636.rst Thx Guido, that reduces the clutter. Co-authored-by: Guido van Rossum --- pep-0636.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pep-0636.rst b/pep-0636.rst index 4ea41308f76..9377858ef98 100644 --- a/pep-0636.rst +++ b/pep-0636.rst @@ -359,7 +359,7 @@ this alternative definition:: class Click: __match_args__ = ("position", "button") - def __init__(self, position_arg, button_arg): + def __init__(self, pos, btn): self.position = position_arg self.button = button_arg ... From 81fad61c4f8e5813a3382c25a1afae4879e578f5 Mon Sep 17 00:00:00 2001 From: John Saponara Date: Sun, 7 Nov 2021 20:29:39 -0500 Subject: [PATCH 3/3] oops, thx again! --- pep-0636.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pep-0636.rst b/pep-0636.rst index 9377858ef98..ccec6ed05ac 100644 --- a/pep-0636.rst +++ b/pep-0636.rst @@ -360,8 +360,8 @@ this alternative definition:: class Click: __match_args__ = ("position", "button") def __init__(self, pos, btn): - self.position = position_arg - self.button = button_arg + self.position = pos + self.button = btn ... The ``__match_args__`` special attribute defines an explicit order for your attributes