Re: Multilevel dicts/arrays v. tuples as keys? [Was: Re: Get keys from a dicionary]

2011-11-14 Thread Tim Golden
On 14/11/2011 10:05, 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

Multilevel dicts/arrays v. tuples as keys? [Was: Re: Get keys from a dicionary]

2011-11-14 Thread Matej Cepl
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

Re: Get keys from a dicionary

2011-11-13 Thread alex23
On Nov 11, 11:31 pm, macm wrote: > > 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. It might be possible to do something using a reverse dictionary and getting rid of the ne

Re: Get keys from a dicionary

2011-11-13 Thread alex23
On Nov 11, 11:31 pm, macm wrote: > > 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. It might be possible to do something using a reverse dictionary and getting rid of the ne

Re: Get keys from a dicionary

2011-11-11 Thread John Gordon
In Gelonida N writes: > > > There is a fast way (trick) to get k1 and k2 as string. > > > > > > Whithout loop all dict. Just it! > If my guessing was correct is this what you are looking for? He said he didn't want to loop over the dict contents. Without that, I don't think there's an answe

Re: Get keys from a dicionary

2011-11-11 Thread Gelonida N
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 > > > > ma

Re: Get keys from a dicionary

2011-11-11 Thread Gelonida N
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 ans

Re: Get keys from a dicionary

2011-11-11 Thread macm
On Nov 11, 2:25 pm, John Gordon wrote: > In <8f5215a8-d08f-4355-a5a2-77fcaa32c...@j10g2000vbe.googlegroups.com> macm > writes: > > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > > That's not valid syntax. > > >    print k1 > >    print k2 > > There is a fast way (tr

Re: Get keys from a dicionary

2011-11-11 Thread John Gordon
In macm writes: > >>> myDict = {} > >>> myDict['foo'] = {} > >>> myDict['foo']['bar'] = 'works' > - > >>> def myFunction( MyObj ): > ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] > ['bar']) > ... # I want inspect this MyObj > ... # what keys was pass > ...

Re: Get keys from a dicionary

2011-11-11 Thread Dave Angel
On 11/11/2011 11:33 AM, macm wrote: Hi Sorry ! My mistake. myDict = {} myDict['foo'] = {} myDict['foo']['bar'] = 'works' - def myFunction( MyObj ): ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] ['bar']) No, it's not. It's a string "works". There's no di

Re: Get keys from a dicionary

2011-11-11 Thread macm
Ok Sorry!! Sorry the noise!! def func(object): print "%s" % object Regards On Nov 11, 2:33 pm, macm wrote: > Hi > > Sorry ! My mistake. > > >>> myDict = {} > >>> myDict['foo'] = {} > >>> myDict['foo']['bar'] = 'works' > > - > > >>> def myFunction( MyObj ): > > ...     # MyObj is a

Re: Get keys from a dicionary

2011-11-11 Thread macm
Hi Sorry ! My mistake. >>> myDict = {} >>> myDict['foo'] = {} >>> myDict['foo']['bar'] = 'works' - >>> def myFunction( MyObj ): ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] ['bar']) ... # I want inspect this MyObj ... # what keys was pass ... print M

Re: Get keys from a dicionary

2011-11-11 Thread John Gordon
In <8f5215a8-d08f-4355-a5a2-77fcaa32c...@j10g2000vbe.googlegroups.com> macm writes: > I pass a nested dictionary to a function. > def Dicty( dict[k1][k2] ): That's not valid syntax. > print k1 > print k2 > There is a fast way (trick) to get k1 and k2 as string. Are you stating t

Re: Get keys from a dicionary

2011-11-11 Thread Jon Clements
On Nov 11, 1: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've tried to underst