Setdefault bypasses __setitem__

Fredrik Lundh fredrik at pythonware.com
Fri Oct 14 02:01:40 EDT 2005


Diez B. Roggisch wrote:

> I rarely find things in python strange or named incorrectly, but this is
> IMHO such a case - setdefault led me to think that using it would set a
> default value to return for _future_ lookups of non-existant keys. That
> semantics is known in e.g. ruby or java.
>
> I think a better name would be getdefault, or even get_setdefault - in
> oppposition to the get(key, d) form.
>
> But now that this became clear to me... I guess I can live with the name :)

as long as you pronounce it correctly (see my earlier post).

</F>






More information about the Python-list mailing list