Pre-PEP: Dictionary accumulator methods

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Mar 19 17:12:57 EST 2005


John Machin wrote:
> Raymond Hettinger wrote:
>> I would like to get everyone's thoughts on two new dictionary
> methods:
> 
> +1 for each.
> 
>> PROBLEMS BEING SOLVED
>> ---------------------
>>
>> The readability issues with the existing constructs are:
>>
>> * They are awkward to teach, create, read, and review.
>> * Their wording tends to hide the real meaning (accumulation).
>> * The meaning of setdefault() 's method name is not self-evident.
> 
> +1 to EACH of the above 3 points.
> 
> A question directed to the folk who had to look up "tally" in the
> dictionary: Which dictionary includes "setdefault", "updateBy", etc?

Are you kidding? If you know what "set" and "default" means, you will be
able to guess what "setdefault" means. Same goes for updateBy.

Of course, I had to look up setdefault in the Python docs the first time
I ran across it, but in the case of tally, I would have to look up both
in the Python docs and in my dictionary.

Reinhold



More information about the Python-list mailing list