Dictionaries and incrementing keys

Asen Bozhilov asen.bozhilov at gmail.com
Tue Jun 14 12:30:38 EDT 2011


Steve Crook wrote:

> Whilst certainly more compact, I'd be interested in views on how
> pythonesque this method is.

Instead of calling function you could use:

d = {}

d[key] = (key in d and d[key]) + 1

Regards.



More information about the Python-list mailing list