Pre-PEP: Dictionary accumulator methods

Raymond Hettinger vze4rx4y at verizon.net
Fri Mar 18 21:22:56 EST 2005


> >        def count(self, value, qty=1):

[Aahz]
> You mean
>     def count(self, key, qty=1)
>
> Right?

Yes.

Also, there is a typo in the final snippet (pure python version of dictionary of
dictionaries).  It should read:

    if key not in d:
        d[key] = {subkey:value}
    else:
        d[key][subkey] = value


Raymond





More information about the Python-list mailing list