In article <[EMAIL PROTECTED]>, Thomas Nelson wrote:
> This is exactly what I want to do: every time I encounter this kind of
> value in my code, increment the appropriate type by one.  Then I'd like
> to go back and find out how many of each type there were.  This way
> I've written seems simple enough and effective, but it's very ugly and
> I don't think it's the intended use of lists.  Does anyone know a
> cleaner way to have the same funtionality?

How about this:

map = {}
def increment(value):
  map[value] = map.get(value, 0) + 1

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

Reply via email to