On 11/11/2011 02:31 PM, macm wrote: > Hi Folks > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > print k1 > print k2 > > There is a fast way (trick) to get k1 and k2 as string. > > Whithout loop all dict. Just it! > > Regards > > macm
I think the answer to the question, that I don't really understand is: No. This cannot be done. However we might help you if you copy a COMPLETE standalone example of your problem and if you try to re-explain once more what exactly you want to do. Ideally tell us even why you want to do it. Perhaps the solution is something completely different. Below I'm doing some guess work: nesteddict = { 'a': { 'A' : 'value1 a_A' , 'B' : 'value2 a_B' }, 'b': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, 'c': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, } def mymagic_function(value): print 'the value is <%s>', value print('There is really no way knowing from where this value came\n' 'except if you tell me in which dictionary you are supposed\n' 'and if I just try to find all matches\n' ) value = nesteddict['a']['B'] mymagic_function(value) -- http://mail.python.org/mailman/listinfo/python-list