+ 1
What would be a good example of a problem where using a tuple as a dictionary key is an effective solution?
2 Respostas
0
possibly if you wanted to "flatten" a multi dimensional array.
for example, if you had valued at x,y co-ordinates, you could use a list of lists:
res=val[x][y]
or a dictionary with a tupple key:
res=val[(x,y)]
The second option would be better if you did not have values at all x and y combinations.
- 1
i imagine that they could be used as a sort of a schema or strict glossary ("a"==="a1")