[issue33235] Better help text for dict.setdefault

2020-10-03 Thread Inada Naoki
Change by Inada Naoki : -- resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue33235] Better help text for dict.setdefault

2020-10-03 Thread Irit Katriel
Irit Katriel added the comment: The help message is now: Help on method_descriptor: setdefault(self, key, default=None, /) Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. This issue should

[issue33235] Better help text for dict.setdefault

2018-04-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Changing docstring can break existing code, therefore it should go only in future new Python version unless it contains a bug. The current docstring in 3.6 doesn't look incorrect to me. The docstring in 3.7 is different.

[issue33235] Better help text for dict.setdefault

2018-04-06 Thread Éric Araujo
Éric Araujo added the comment: Note that if we switch the order like you propose, we don’t need to use dict.get: set D[k]=d if k not in D then return D[k] I suspect the current doc was written the way it is because it matches the actual implementation. --

[issue33235] Better help text for dict.setdefault

2018-04-06 Thread Éric Araujo
Éric Araujo added the comment: The two lines are equivalent! `d.setdefault(key, default)` does return the same thing as `d.get(key, default)`, and then sets `d[key] = default` if the get method went into the “key was not found, let’s return default” branch. --

[issue33235] Better help text for dict.setdefault

2018-04-06 Thread Paddy McCarthy
New submission from Paddy McCarthy : Hi, I was answering some question and used dict.setdefault as part of the solution and posted the help() on it as part of my answer. The help was this: In [15]: help(mapper.setdefault) Help on built-in function setdefault: