dictionary into desired variable....
Zero Piraeus
schesis at gmail.com
Fri Aug 10 10:36:44 EDT 2012
:
> suppose you have a dictionary that looks like this:
>
> x = [1,3,6,1,1] which should represent a certain other variable.
That's a list, not a dict.
> in reality it would represent:
>
> y[1][3][6][1][1]
>
> Now, how do I write a python routine, that points in this dictionary,
> where I should receive or set other values.
>>> x = [1, 3, 6, 1, 1]
>>> y = [0, [0, 1, 2, [0, 1, 2, 3, 4, 5, [0, [0, 'bingo!']]]]]
>>> def drill(tree, path):
... target = tree
... for step in path:
... target = target[step]
... return target
...
>>> drill(y, x)
'bingo!'
>>>
-[]z.
More information about the Python-list
mailing list