dict.setdefault() (Patch#101102) (was: Re: [Python-Dev] Re: A small proposed change to dictionaries' "get" method...)

Skip Montanaro skip@mojam.com (Skip Montanaro)
Tue, 8 Aug 2000 08:24:06 -0500 (CDT)


    >> dict.getorset('hi', []).append(42)  # getorset is my favorite

    Peter> 'getorset' is a *MUCH* better name compared to 'default' or
    Peter> 'setdefault'.

Shouldn't that be getorsetandget?  After all, it doesn't just set or get it
gets, but if it's undefined, it sets, then gets.

I know I'll be shouted down, but I still vote against a method that both
sets and gets dict values.  I don't think the abbreviation in the source is
worth the obfuscation of the code.

Skip