I\'m currently re-engaging with Python after a long absence and loving it. However, I find myself coming across a pattern over and over. I keep thinking that there must be a
For Python >= 2.5 you can do the following:
foo[bar] = 1 if bar not in foo else foo[bar]+1