[Python-3000] A request to keep dict.setdefault() in 3.0 (original) (raw)

Brandon Craig Rhodes brandon at rhodesmill.org
Mon Jul 9 23:01:38 CEST 2007


Barry Warsaw <barry at python.org> writes:

However, .setdefault() is a horrible name because it's not clear from the name that a 'get' operation also happens.

Agreed! From the name, a clever but naive user would assume that "setdefault" sets what value the dictionary returns when a key does not exist. On first encountering the name, one imagines:

d = {} d[1] KeyError: 1 d.setdefault('missing') d[1] 'missing'

-- Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon



More information about the Python-3000 mailing list