-1 on set increment.
I think this makes your intent much clearer:

.d={}
.for word in text.split():
.    d.tally(word)
.    if word.lower() in ["a","an","the"]:
.        d.tally(word,-1)

or perhaps simplest:

.d={}
.for word in text.split():
.    if word.lower() not in ["a","an","the"]:
.        d.tally(word)

Personally, I'm +1 for tally(), and possibly tallyList() and tallySet()
to complete the thought for the cumulative container cases.  I think
there is something to be gained if these methods get named in some
similar manner.

For those dead set against tally() and its ilk, how about accum(),
accumList() and accumSet()?

-- Paul

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

Reply via email to