"Michael Spencer" <[EMAIL PROTECTED]> wrote:

> I could imagine a class: accumulator(mapping, default, incremetor) such that:
>   >>> my_tally = accumulator({}, 0, operator.add)
>   or
>   >>> my_dict_of_lists = accumulator({}, [], list.append)
> or
>   >>> my_dict_of_sets = accumulator({}, set(), set.add)
>
> then: .accumulate(key, value) "does the right thing" in each case.
>
> a bit cumbersome, because of having to specify the accumulation method, but
> avoids adding methods to, or sub-classing dict
>
> Michael

That's the equivalent of reduce() for mappings. Given the current trend of 
moving away from
traditional functional features (lambda,map,filter,etc.), I would guess it's 
not likely to become
mainstream.

George


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to