Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26873 > unrolled thread
| Started by | Zero Piraeus <schesis@gmail.com> |
|---|---|
| First post | 2012-08-10 10:36 -0400 |
| Last post | 2012-08-10 10:36 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: dictionary into desired variable.... Zero Piraeus <schesis@gmail.com> - 2012-08-10 10:36 -0400
| From | Zero Piraeus <schesis@gmail.com> |
|---|---|
| Date | 2012-08-10 10:36 -0400 |
| Subject | Re: dictionary into desired variable.... |
| Message-ID | <mailman.3163.1344609427.4697.python-list@python.org> |
: > 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.
Back to top | Article view | comp.lang.python
csiph-web