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


Groups > comp.lang.python > #57003

Re: pointer and python

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'important,': 0.07; 'suppose': 0.07; 'string': 0.09; 'attributes': 0.09; 'val': 0.09; 'attribute,': 0.16; 'dict': 0.16; 'fetch': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'replace': 0.24; 'question': 0.24; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; "can't": 0.35; 'but': 0.35; 'skip:m 40': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'according': 0.40; "you're": 0.61; 'dear': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'dic': 0.84; 'dict()': 0.84; 'reply- to:addr:python.org': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=bKAvfpOZ c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=05MOGALpfCEA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=7mPnoQFArIUA:10 a=IkE7VfS49TYXOP7czNgA:9 a=wPNLvfGTeEIA:10
X-AUTH mrabarnett:2500
Date Fri, 18 Oct 2013 00:54:31 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: pointer and python
References <1382051859.5449.23.camel@debian>
In-Reply-To <1382051859.5449.23.camel@debian>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1188.1382054075.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382054075 news.xs4all.nl 15975 [2001:888:2000:d::a6]:39740
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57003

Show key headers only | View raw


On 18/10/2013 00:17, Mohsen Pahlevanzadeh wrote:
> Dear all,
>
> Suppose I have the following code:
> ##########################################3
> mydic = dict()
> mydict.update({'string':QtGui.QCheckBox()}) ## suppose this dic has many
> value with some string and QCheckBox Object
>
If you do this, you're giving them all the same key 'string', so only 
the last will be remembered.

> #####Then i have itreate it :
>
> for key, val in mydict.items():
>      setattr(self,"%s" % val,XXX) ###===> this line is the given line
>      getattr(self,"%s" % val)
>
> ############################################33
> According to the above code, i fetch a set of object from dict and set
> them as attribute, But question is , val has  value and it's important,
> and i can't replace any other value with it, What i replace with XXX in
> setattr ?
>
Why are you using attributes anyway? Why not just store them in a dict?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: pointer and python MRAB <python@mrabarnett.plus.com> - 2013-10-18 00:54 +0100

csiph-web