Raymond Hettinger wrote:
I would like to get everyone's thoughts on two new dictionary methods:

        def count(self, value, qty=1):
            try:
                self[key] += qty
            except KeyError:
                self[key] = qty

        def appendlist(self, key, *values):
            try:
                self[key].extend(values)
            except KeyError:
                self[key] = list(values)

They look as a special-case to me. They don't solve the problem for lists of sets or lists of deques for instance, not to mention other possible user-defined containers.


defaultdicts look to me as a solution that is more elegant and solves more problems. What is the problem with them?

--
Ciao,
Matteo
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to