dictionary idiom needed

Brandon your.master at gmail.com
Thu Dec 11 18:08:04 CET 2008

Hi all,

I have a series of lists in format ['word', 'tagA', 'tagB'].  I have
converted this to a few dicts, such as one in which keys are tuples of
('word', 'tagB'), and the values are the number of times that key was
found.  I need an dictionary idiom whereby I can find all instances of
a given 'word' with any 'tagB', and then subdivide into all instances
of a given 'tagB'.  In both cases I would want the value as a count of
all instances found.  Can this be done with dictionaries?  Or should I
back up and do this with lists?  All of the nested for loops I have
tried return replicated results, so I can't trust those values.

Thanks for any pointers,


More information about the Python-list mailing list