Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'assign': 0.07; 'suppose': 0.07; 'python': 0.09; 'dict': 0.09; 'subject:into': 0.09; 'aug': 0.13; 'sat,': 0.15; 'dictionary,': 0.16; 'dictionary.': 0.16; 'helps!': 0.16; 'idx': 0.16; 'mapping,': 0.16; 'mean,': 0.16; 'unordered': 0.16; 'variable.': 0.16; 'wrote:': 0.17; 'keys': 0.22; 'received:mail-bk0-f46.google.com': 0.22; 'sorry,': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'looks': 0.26; 'charset:iso-8859-15': 0.26; 'am,': 0.27; 'question': 0.27; 'received:209.85.214.46': 0.27; 'start,': 0.27; 'chris': 0.28; 'represent': 0.28; 'dictionary': 0.29; 'points': 0.29; "skip:' 10": 0.30; 'certain': 0.33; '11,': 0.33; 'clarify': 0.33; 'values.': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'from:addr:googlemail.com': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'list,': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'more': 0.63; 'subject:....': 0.65; 'receive': 0.71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=gktogn9mVLQqMB/gUzJ35O+0v43NVP8a5tleTwU0p+M=; b=RV62caaLF4uE0nBWTSW+AMSjvWoH+3j/fZVBfyM62vh8QF1USq8RtFPeki9p6OVpG1 bt/NDPzdyOH9br1IurZOv1BjGMISKnW6dWVK8ha6gAHSRkAoVIwwA89UIE05t1zRox6X JyQMQv10unU3Efd+eFa6eXZqxEm+0wGoLpfvssCNP6z7ROv0wg507bQEOnijlykBB3/U qNae2V72n7gVuOC//FZM4XNo9IvymhNJIcLI59uOZSLrPJSsPkkU2swPIVLtwxd3+ZsA 1eeCTX0z89Yp6yMGOQcbYK4d+AP2k9Cjc9x1AwnOoTJqEzdsGWjYRYNyj2omFCHJCyV4 3u2A== Date: Fri, 10 Aug 2012 17:31:48 +0200 From: Tamer Higazi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.6esrpre) Gecko/20120730 Thunderbird/10.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: dictionary into desired variable.... References: <50251477.7010507@googlemail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 61 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344612712 news.xs4all.nl 6863 [2001:888:2000:d::a6]:54291 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26877 Sorry, I ment of course list.... what I exaclty ment is that if I assign value = Number that I automaticly assign y[1][3][6][1][1] a new number. more detailled explained: let us say a would be x = [2,5,4] y = a[3] if I change y to [] I want the result to be x = [2,5,[]] and that's automaticly independently how deep i dig. Sorry for the inconvenience. Tamer Am 10.08.2012 16:31, schrieb Chris Angelico: > On Sat, Aug 11, 2012 at 12:02 AM, Tamer Higazi wrote: >> Hi! >> suppose you have a dictionary that looks like this: >> >> x = [1,3,6,1,1] which should represent a certain other variable. >> >> 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. > > For a start, that looks like a list, not a dictionary. A dict in > Python is a mapping, eg a hashtable - an unordered pairing of keys and > values. But this might do what you want: > > value = y > for idx in x: > value = value[idx] > > At the end of that, 'value' will be the same as 'y[1][3][6][1][1]'. > > If that's not what you mean, you may want to clarify your question some. > > Hope that helps! > > Chris Angelico