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[
[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)
> ...
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
[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
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
[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':
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
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:
>
> +++
...
--
http://mail.python.org/mailman/listinfo/python-list
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
10 matches
Mail list logo