[Tutor] a generic table data structure for table / 2d array / lookup table?
Marcus Goldfish
magoldfish at gmail.com
Sat May 28 10:05:54 CEST 2005
Before I try to reinvent the wheel, can anyone point me to a data
structure suitable for storing non-numeric, 2-d arrays. For instance,
something that can store the following:
A B C D
1 'cat' 3 object 9
J 4 [1] 5 6
where the column and row labels in this example are ['A','B','C','D']
and [1,'J'], respectively. I need to access (set and get values) by
cell, row, and column.
I have a solution using 2-tuple keys and a dict, e.g., d[('A',1)], but
it seems kludgy and doesn't handle the row/column access.
Any pointers or code snippets would be appreciated!
Marcus
More information about the Tutor
mailing list