Pre-PEP: Dictionary accumulator methods

BJörn Lindqvist bjourne at gmail.com
Sun Mar 20 11:13:38 EST 2005


I like count() and appendlist() or whatever they will be named. But I
have one question/idea:

Why does the methods have to be put in dict? Can't their be a subtype
of dict that includes those two methods? I.e.:

.histogram = counting_dict()
.for ch in text:
.    histogram.count(ch)

Then maybe some more methods can be added tailor-mode for these two
types of dicts?:

.for ch in string.ascii_letters:
.    print "Frequency of %s = %d." % (ch, histogram.freq(ch))

Or something, you get the idea.

-- 
mvh Björn



More information about the Python-list mailing list