Matej Cepl wrote: > Dne 11.11.2011 14:31, macm napsal(a): >> def Dicty( dict[k1][k2] ): > > When looking at this I returned to the question which currently rolls in > my mind: > > What's difference/advantage-disadvantage betweeng doing multi-level > dicts/arrays like this and using tuple as a key? I.e., is it more > Pythonic to have > > dict[k1,k2] > > instead?
If you need lookup only I'd prefer tuples, but sometimes you may want to retrieve all values with a certain k1 and d[k1] is certainly more efficient than [(k2, v) for (k1, k2), v in d.items() if k1 == wanted] -- http://mail.python.org/mailman/listinfo/python-list