Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26876
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'attribute': 0.05; 'class,': 0.07; 'nested': 0.07; 'suppose': 0.07; 'python': 0.09; '__init__': 0.09; 'fetch': 0.09; 'none.': 0.09; 'subject:into': 0.09; 'cc:addr:python-list': 0.10; 'student': 0.15; 'value.': 0.15; 'assumptions': 0.16; 'dictionary,': 0.16; 'pointer,': 0.16; 'pointers.': 0.16; 'variable.': 0.16; 'write,': 0.16; 'wrote:': 0.17; 'pointed': 0.17; 'bit': 0.21; 'supposed': 0.21; 'keys': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'programming': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'am,': 0.27; 'language.': 0.27; 'question': 0.27; "doesn't": 0.28; 'fixed': 0.28; 'actual': 0.28; 'represent': 0.28; 'dictionary': 0.29; 'points': 0.29; 'that.': 0.30; 'saves': 0.30; 'function': 0.30; 'code': 0.31; 'gets': 0.32; 'could': 0.32; 'certain': 0.33; 'values.': 0.33; "can't": 0.34; 'list': 0.35; 'data,': 0.35; 'generic': 0.35; 'returning': 0.35; 'so,': 0.35; 'doing': 0.35; 'something': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'method': 0.36; 'useful': 0.36; 'should': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'mean': 0.38; 'some': 0.38; 'takes': 0.39; 'received:192': 0.39; 'list,': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'first': 0.61; 'kind': 0.61; 'more': 0.63; 'choose': 0.65; 'subject:....': 0.65; 'header :Reply-To:1': 0.68; 'receive': 0.71; 'received:74.208': 0.71; 'sounds': 0.71; 'reply-to:no real name:2**0': 0.72; 'presumably': 0.84; 'routines': 0.84 |
| Date | Fri, 10 Aug 2012 11:14:05 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | Tamer Higazi <th982a@googlemail.com> |
| Subject | Re: dictionary into desired variable.... |
| References | <50251477.7010507@googlemail.com> |
| In-Reply-To | <50251477.7010507@googlemail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:tQvco1aAQl/eb4nXCRxOs8zj7H2eyIekwePwsfA6tVn sVBraPeYdS76vzCZRVFL+t1DUWGtTj/7kwqSCT7xOYRRxqXoic tdjep1QeGlve4LYbSuGs7P0zOf+UgpNK5o1kacz2dZE3yx8aDT K1C1rIskaMa3MID0AquTG95bdWVRsMVz/3gzprTau2SwIYzyzF qOU7YShlPPFo+Gdc5YMfZgbJjLttjMBRNl/fMRzGRa1kZb2fZ1 4ozUdougG1XTpqrwgq9Oj3fF2sbw/w5/9W1hEKI9ibiCOLElYp V5yEaQQogYXW+ka5LSnrysSGCigyP7SovdEVOQuUVdhdNGMvQ= = |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | d@davea.name |
| 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.3165.1344611670.4697.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1344611670 news.xs4all.nl 6970 [2001:888:2000:d::a6]:48053 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26876 |
Show key headers only | View raw
On 08/10/2012 10: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. > Others have pointed out how you could "receive" a value from that. Doing a setter would be tricker. But I'd want to start with the question of just what you're really looking for. Is this an assignment, so it doesn't have to actually make sense? If so, could we please have the actual wording. x is not a dictionary, and Python doesn't have routines nor pointers. Perhaps it's a generic programming class, and the student gets to choose the language. If it's indeed intended to model some kind of useful data, could we know a bit more about the constraints? is y supposed to be a nested list, or a nested dictioary, or something else? How is this nested list/dict first created? Do you need to have other parts of the code access the raw, nested Something. Are there always going to be 5 subscripts, and are each constrained to be in a fixed range? If it's a nested dictionary, are the keys always integers? Since a python function or method can't return a pointer, presumably you mean for a function or method to fetch or store a value. Sounds like what you want is a class, where the __init__ method takes a nested something, y and saves it as an attribute _y. And there are at least two more methods in that class, fetch() that takes a list of ints, and returns a value. And store() that takes a list of ints and a value, and mutates the _y, returning None. The store() method is a good bit trickier to write, depending on the assumptions above. -- DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: dictionary into desired variable.... Dave Angel <d@davea.name> - 2012-08-10 11:14 -0400
csiph-web