Re: how to add object from dict

2013-10-17 Thread Mohsen Pahlevanzadeh
I sovled with : for key, val in self.projectsInstance.addOnFieldsInstance.items(): setattr(self,"%s" % val,val) instance = getattr(self,"%s" % val) print "%s %s " % (key,val) QtCore.QObject.connect(instance, Qt

Re: how to add object from dict

2013-10-17 Thread Steven D'Aprano
On Thu, 17 Oct 2013 11:46:52 +1100, Chris Angelico wrote: > On Thu, Oct 17, 2013 at 11:43 AM, MRAB > wrote: >> I'm guessing, but perhaps you need: >> >> instance = getattr(self, "%s" % key) > > How's that different from getattr(self,str(key))? Are you blind man? The first one has a % symbol

Re: how to add object from dict

2013-10-17 Thread MRAB
On 17/10/2013 01:46, Chris Angelico wrote: On Thu, Oct 17, 2013 at 11:43 AM, MRAB wrote: I'm guessing, but perhaps you need: instance = getattr(self, "%s" % key) How's that different from getattr(self,str(key))? I'm trying to make the bug clearer for the OP by doing it the same way as

Re: how to add object from dict

2013-10-16 Thread Mohsen Pahlevanzadeh
On Thu, 2013-10-17 at 11:46 +1100, Chris Angelico wrote: > On Thu, Oct 17, 2013 at 11:43 AM, MRAB wrote: > > I'm guessing, but perhaps you need: > > > > instance = getattr(self, "%s" % key) > > How's that different from getattr(self,str(key))? > > ChrisA I get the string of CheckBox instead

Re: how to add object from dict

2013-10-16 Thread Ben Finney
Mohsen Pahlevanzadeh writes: > You say right, but i don't any time to read all of content of > http://sscce.org/ , But when i saw its description , i found out , > it's a set of law for good answer/question That's right. Please take the time to help us to help you, by following that advice. > A

Re: how to add object from dict

2013-10-16 Thread Chris Angelico
On Thu, Oct 17, 2013 at 11:43 AM, MRAB wrote: > I'm guessing, but perhaps you need: > > instance = getattr(self, "%s" % key) How's that different from getattr(self,str(key))? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: how to add object from dict

2013-10-16 Thread MRAB
On 16/10/2013 23:14, Mohsen Pahlevanzadeh wrote: Dear all, I have the following code in projects.py: ##33 for row in xrange(len(uniqueFields)): instance = QtGui.QCheckBox(uniqueFields[row]) projectsFindInstance.projectsInstan

Re: how to add object from dict

2013-10-16 Thread Mohsen Pahlevanzadeh
You say right, but i don't any time to read all of content of http://sscce.org/ , But when i saw its description , i found out , it's a set of law for good answer/question, Also i saw PEP 8 , it's like old style C, and i like CamelCase. But now, all of my code doesn't work and related to the given

Re: how to add object from dict

2013-10-16 Thread Ben Finney
Mohsen Pahlevanzadeh writes: > Thank you for your useful link , i paste my code into [an external > pastebin service] I'm glad you liked the link, but you haven't followed its advice :-) Also, pointing us to a pastebin is not helpful. Please use a user-agent that won't mangle your code so you c

Re: how to add object from dict

2013-10-16 Thread Mohsen Pahlevanzadeh
On Thu, 2013-10-17 at 10:45 +1100, Ben Finney wrote: > Mohsen Pahlevanzadeh writes: > > > and another file,(projectsFind.py) i have the following code: > > #3 > > for key, val in > > self.projectsInstance.addOnFieldsInstance.

Re: how to add object from dict

2013-10-16 Thread Ben Finney
Mohsen Pahlevanzadeh writes: > and another file,(projectsFind.py) i have the following code: > #3 > for key, val in > self.projectsInstance.addOnFieldsInstance.items(): > instance = getattr(self,"%s" % val) >

how to add object from dict

2013-10-16 Thread Mohsen Pahlevanzadeh
Dear all, I have the following code in projects.py: ##33 for row in xrange(len(uniqueFields)): instance = QtGui.QCheckBox(uniqueFields[row]) projectsFindInstance.projectsInstance.addOnFieldsInstance.update({"%s" % uniqueFields[ro