I am writing my PyQt4 program and I manipulate many dictionaries. No problem in the file script itself, but now need to use dictionaries that are not in my file script, and I don’t know how to correctly import and use them to update my “real” dictionaries.
All my dictionaries are declared in my init constructor at the top of my program.
Here is a bit of my program which show a sample dictionary, in a function :
self.dicoMentalRay = { 'projectDirectory' : self.mentalrayProjectDirectory_Text.text(),
'sceneFilename' : self.mentalrayProjectSceneFilename_Text.text(),
'renderer' : self.mentalrayRenderingRenderer_Text.text() }
and here how it is supposed to update after I clicked on a button (in another function) :
self.dicoMentalRay.update(dicoMentalRay2)
The “dicoMentalRay2” is supposed to be in another .py file, in the same directory of my script. I import it well with
import dico
The problem is that I always get the same error :
NameError: global name 'dicoMentalRay2' is not defined
I think the problem is that my “dico.py” is badly written. Indeed, I only write a new dictionary in it, and nothing else, like class or function.
How am I supposed to do ? Thanks !
To use dicoMentalRay2 from dico file, you have to use
or