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


Groups > comp.lang.python > #56984

Re: how to add object from dict

Subject Re: how to add object from dict
From Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org>
Date 2013-10-17 23:24 +0330
References (1 earlier) <7wwqlcixup.fsf@benfinney.id.au> <1381968532.12853.4.camel@debian> <7wob6oiwgw.fsf@benfinney.id.au> <1381970241.12853.9.camel@debian> <7wk3hciuul.fsf@benfinney.id.au>
Newsgroups comp.lang.python
Message-ID <mailman.1174.1382039669.18130.python-list@python.org> (permalink)

Show all headers | View raw


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,
QtCore.SIGNAL(_fromUtf8("stateChanged (int)")), lambda:
self.projectsInstance.setFilterDict_Find("TWCH",self,key,instance.checkState(),instance))
##########################################
In above loop i have probelm : instead of call connect function
according to number of my for, my connect function initilize and call
according to last (key, val),

Do you have any idea?

--mohsen
On Thu, 2013-10-17 at 11:50 +1100, Ben Finney wrote:
> Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> 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.
> 
> > Also i saw PEP 8 , it's like old style C, and i like CamelCase.
> 
> TitleCaseNames are fine (PEP 8 recommends TitleCaseNames for classes),
> camelCase is inconsistent and hence deprecated.
> 
> Regardless of what you like, if you're presenting code for others to
> read – such as in a discussion forum where you'd like others to read
> your code and help you – you are well advised to follow PEP 8 so your
> code is easier for us to read.
> 
> > But now, all of my code doesn't work and related to the given
> > traceback of i sent you.
> 
> I'll wait for your short, self-contained, complete example.
> 
> -- 
>  \         “I think there is a world market for maybe five computers.” |
>   `\                             —Thomas Watson, chairman of IBM, 1943 |
> _o__)                                                                  |
> Ben Finney
> 

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


Thread

Re: how to add object from dict Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-10-17 23:24 +0330

csiph-web