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


Groups > comp.lang.python > #57003 > unrolled thread

Re: pointer and python

Started byMRAB <python@mrabarnett.plus.com>
First post2013-10-18 00:54 +0100
Last post2013-10-18 00:54 +0100
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.


Contents

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

#57003 — Re: pointer and python

FromMRAB <python@mrabarnett.plus.com>
Date2013-10-18 00:54 +0100
SubjectRe: pointer and python
Message-ID<mailman.1188.1382054075.18130.python-list@python.org>
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?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web