[issue38998] dict.setdefault (setdefault of dictionary)

Rémi Lapeyre report at bugs.python.org
Sun Dec 8 17:39:03 EST 2019


Rémi Lapeyre <remi.lapeyre at henki.fr> added the comment:

The documentation is correct, in Python argument are computed before the
call to a function, not when they are used. You can try other functions
than dict.setdefault() and see that the behaviour is always the same.

Le dim. 8 déc. 2019 à 22:47, da-dada <report at bugs.python.org> a écrit :

>
> da-dada <georg.klingenberg at travedsl.de> added the comment:
>
> I have no problem of making my programme run properly (asking first if in
> dict etc), but I just read the docu of dict.setdefault
>
> setdefault(key[, default])
> If key is in the dictionary, return its value. If not, insert key with a
> value of default and return default. default defaults to None.
>
> and it clearly reads if the key is.. return its value, with a full stop;
> so either the docu is wrong (but proposes exactly the needed shortcut) or
> python is as it is: come in & find out
>
> ----------
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <https://bugs.python.org/issue38998>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38998>
_______________________________________


More information about the Python-bugs-list mailing list