how to add object from dict

Ben Finney ben+python at benfinney.id.au
Wed Oct 16 19:45:34 EDT 2013


Mohsen Pahlevanzadeh <mohsen at pahlevanzadeh.org> 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)
>             print val
>             #QtCore.QObject.connect(instance,
> QtCore.SIGNAL(_fromUtf8("stateChanged (int)")),
>                                 #lambda:
> self.projectsInstance.setFilterDict_Find("TWCH",self,"addonfields",instance.CheckState(),instance))
> ######################################################################3

The above code has been mangled, and the indentation isn't correct. I
don't want to guess what it was originally; better that you find a user
agent which won't wrap your code lines.

The code is also difficult to read because it's got a lot of
camelCaseNames and it's hard to see what the intent is. (I'd advise
improving the code to conform to PEP 8, which will make your code easier
to discuss with the Python community.)

Lastly, it's not complete: we can't run it to see what you're seeing.

Please re-work (or create) a short, self-contained, complete example
that shows the behaviour <URL:http://sscce.org/>.

-- 
 \     “Wrinkles should merely indicate where smiles have been.” —Mark |
  `\                                    Twain, _Following the Equator_ |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list