From 9cac0ec7b583222a278cb7de0e1ce21c116a1001 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Dec 2024 23:41:49 +0000 Subject: [PATCH 1/2] Document that dict.setdefault takes no keyword arguments Running ```python {}.setdefault("a", default=1) ``` gives: ``` TypeError: dict.setdefault() takes no keyword arguments ``` --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 191827526e890f..dd0ee59df3039d 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4682,7 +4682,7 @@ can be used interchangeably to index the same dictionary entry. .. versionadded:: 3.8 - .. method:: setdefault(key, default=None) + .. method:: setdefault(key, default=None, /) If *key* is in the dictionary, return its value. If not, insert *key* with a value of *default* and return *default*. *default* defaults to From 6730fe8ffb4c80bf31bb3a1a9c89dc7019cd1162 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 25 Mar 2025 13:41:27 +0000 Subject: [PATCH 2/2] Add positional-only indicator to `get` method. --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index dd0ee59df3039d..42fc283548b394 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4640,7 +4640,7 @@ can be used interchangeably to index the same dictionary entry. such as an empty list. To get distinct values, use a :ref:`dict comprehension ` instead. - .. method:: get(key, default=None) + .. method:: get(key, default=None, /) Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to ``None``, so that this method