Setdefault bypasses __setitem__
Diez B. Roggisch
deets at web.de
Thu Oct 13 14:20:57 CEST 2005
> Are we talking about the same setdefault()?
> D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
> There is no per-instance default value just on per call:
Oh. You're right. I was somehow under the impression that setdefault is
per-instance, so that I can avoid
instead, for all keys, and get no more KeyErrors. But then you are
right of course.
More information about the Python-list