how can I avoid abusing lists?
Jon Ribbens
jon+usenet at unequivocal.co.uk
Fri Jul 7 14:31:53 EDT 2006
More information about the Python-list mailing list
Fri Jul 7 14:31:53 EDT 2006
- Previous message (by thread): how can I avoid abusing lists?
- Next message (by thread): how can I avoid abusing lists?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <1152289113.007295.23320 at s13g2000cwa.googlegroups.com>, 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 ?
- Previous message (by thread): how can I avoid abusing lists?
- Next message (by thread): how can I avoid abusing lists?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list