I’m using Jython if that’s relevant.
util.py:
globals = {}
#...
globals["foo"] = "bar"
globals["baz"] = "qux"
main.py:
import util
for key, value in util.globals.iteritems():
print "Key: %s, Value: %s" % (key, value)
My IDE (PyDev) underlines only ‘iteritems’ and tells me Undefined variable from import: iteritems
Yet the program runs and works as I expect it to.
I also get unresolved import errors on every from x import y that I do, and all of those imports work fine when I run the program too. Not sure if this is related.
It thinks you’re taking about org.python.util (or, a less likely possibility, distutils.util) because the modules have the same name, and it knows those imports don’t exist there.
You also shouldn’t ever use the name
globalsbecause there is a builtin calledglobals().Rename the module and the variable and you shouldn’t have a problem.