[Python-Dev] setdefault's second argument

Barry Warsaw barry at python.org
Tue Aug 30 22:18:38 CEST 2005


On Tue, 2005-08-30 at 14:53, Fredrik Lundh wrote:

> Some kind of symmetry with get, probably.  if
> 
>     d.get(x)
> 
> returns None if x doesn't exist, it makes some kind of sense that
> 
>     d.setdefault(x)

I think that's right, and IIRC the specific detail about the optional
second argument was probably hashed out in private Pythonlabs email, or
over a tasty lunch of kung pao chicken.  I don't have access to my
private archives at the moment, though the public record seems to start
about here:

http://mail.python.org/pipermail/python-dev/2000-August/007819.html

> Anyone remember why nobody managed to come up with a better name
> for setdefault (which is probably the worst name ever given to a method
> in the standard Python distribution) ?

Heh.

http://mail.python.org/pipermail/python-dev/2000-August/008059.html

> (if I were in charge, I'd rename it to something more informative.

Maybe like getorset() <wink>.

Oh, and yeah, I don't care if we change .setdefault() to require its
second argument -- I've never used it without one.  But don't remove the
method, it's quite handy.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050830/e7a714ee/attachment.pgp


More information about the Python-Dev mailing list