Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26873

Re: dictionary into desired variable....

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <z@etiol.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'suppose': 0.07; 'python': 0.09; '[0,': 0.09; '[1,': 0.09; 'received:209.85.213.46': 0.09; 'received:mail-yw0-f46.google.com': 0.09; 'subject:into': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'dictionary,': 0.16; 'path:': 0.16; 'variable.': 0.16; '>>>': 0.18; 'cc:2**0': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'tree': 0.27; 'message-id:@mail.gmail.com': 0.27; 'represent': 0.28; 'dictionary': 0.29; 'points': 0.29; "skip:' 10": 0.30; 'certain': 0.33; 'values.': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'step': 0.39; 'list,': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'subject:....': 0.65; 'receive': 0.71; 'dict.': 0.84
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:x-originating-ip:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=2aoHfU2f9NVJBTRgC7gI3X1GS09/G+cw3Mbi+sEd948=; b=ld8SGqPdhKJMJjxqpgKFR0MZC4ors66nFJF1M8oqZzRYXZVCK2vNtQfK6DGr2v6Dtr 6hNy3Lrd7gn8AbTUVn+2UV1PPoH1pnfloEmnfMmgs5782DNuDaVxOdABMBhuWT0e74yD nU0Ss7IvGZbsyjTkU7yZWRQ90q/Yw4vAE+V7/2BidrEZqXs6f/WpbpgoOpOKZSRmrdDK wLPyHC4OZkp6f457v0of/LhwL0DyqRZ8LxhbwU5Am4t9K/EmGd03yIoJZOM2NYrtOWyi 7eyHl5ZW6CLjSotAsNw16K7+MwxtGd1Fp53Nix2J0QsiDpvElr63BfOIPrNhbzh1XANZ O6xg==
MIME-Version 1.0
Sender z@etiol.net
X-Originating-IP [190.104.27.26]
In-Reply-To <50251477.7010507@googlemail.com>
References <50251477.7010507@googlemail.com>
From Zero Piraeus <schesis@gmail.com>
Date Fri, 10 Aug 2012 10:36:44 -0400
X-Google-Sender-Auth UsxI3A0DrD_ylMsV3stL_O8W2PM
Subject Re: dictionary into desired variable....
To Tamer Higazi <th982a@googlemail.com>
Content-Type text/plain; charset=UTF-8
X-Gm-Message-State ALoCoQm8kxsA5uJqNhM+vKj8jcH7VnoXkUBgf04kiZrhjaHrkhzJg3F7hhZ0+Cn/sZPKf8E/JWKb
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3163.1344609427.4697.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1344609427 news.xs4all.nl 6964 [2001:888:2000:d::a6]:39416
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26873

Show key headers only | View raw


:

> 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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: dictionary into desired variable.... Zero Piraeus <schesis@gmail.com> - 2012-08-10 10:36 -0400

csiph-web