Re: idea on how to get/set nested python dictionary values

2006-08-16 Thread [EMAIL PROTECTED]
metaperl wrote: > [EMAIL PROTECTED] wrote: > > > | would use a recursive approach for this - given that you have a sort > > of recursive datastructure: > > > > py> def SetNewDataParam2(Data, NewData): > > ... if type(Data[Data.keys()[0]]) == type(dict()): > > ... SetNewDataParam2(Data[

Re: idea on how to get/set nested python dictionary values

2006-08-16 Thread metaperl
[EMAIL PROTECTED] wrote: > | would use a recursive approach for this - given that you have a sort > of recursive datastructure: > > py> def SetNewDataParam2(Data, NewData): > ... if type(Data[Data.keys()[0]]) == type(dict()): > ... SetNewDataParam2(Data[Data.keys()[0]], NewData) > ...

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread jojoba
Once again, Thanks to all I did not expect to receive such a response. Very very helpful indeed, jojoba o(-_-)o -- http://mail.python.org/mailman/listinfo/python-list

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread Simon Forman
[EMAIL PROTECTED] wrote: > | would use a recursive approach for this - given that you have a sort > of recursive datastructure: > > py> def SetNewDataParam2(Data, NewData): > ... if type(Data[Data.keys()[0]]) == type(dict()): Note: |>> type(dict()) is dict True "dict" *is* a type... -- ht

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread bearophileHUGS
Like for the list.sort() method, to remind you that this function operate by side effect, maybe it's better if it doesn't return the modified nested dict: def setNested(nest, path, val): nest2 = nest for key in path[:-1]: nest2 = nest2[key] nest2[path[-1]] = val Bye, bearophil

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread bearophileHUGS
[EMAIL PROTECTED] wrote: > py> def SetNewDataParam2(Data, NewData): > ... if type(Data[Data.keys()[0]]) == type(dict()): > ... SetNewDataParam2(Data[Data.keys()[0]], NewData) > ... else: > ... Data[Data.keys()[0]] = NewData > ... > ... return Data > py> Data = {'a':{'b':

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread jojoba
hey thank you so much! that should work fantastically i like your method much better more elegant thanks! jojoba =) -- http://mail.python.org/mailman/listinfo/python-list

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread [EMAIL PROTECTED]
jojoba wrote: > hello! > > i am trying to come up with a simple way to access my values in my > nested python dictionaries > > here is what i have so far, but i wanted to run it by the geniuses out > there who might see any probems with this... > here is an example: > > +++

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread jojoba
... -- http://mail.python.org/mailman/listinfo/python-list

idea on how to get/set nested python dictionary values

2006-08-15 Thread jojoba
hello! i am trying to come up with a simple way to access my values in my nested python dictionaries here is what i have so far, but i wanted to run it by the geniuses out there who might see any probems with this... here is an example: +++ def SetNewDataParam