On 15/06/2015 12:03, David Aldrich wrote:
Hi
I have defined a dictionary in a module:
mydir.py:
REG_LOOKUP = {
'REG_1' : some_value1,
'REG_2' : some_value2,
}
How would I import that dictionary from my main() function (which lives in a
different module) please?
Best regards
David
import othermodule
...
othermodule.REG_LOOKUP{whatever}
OR
from othermodule import REG_LOOKUP
...
REG_LOOKUP{whatever}
You can also use
from othermodule import *
but this is frowned upon as it pollutes your namespace, potentially
giving all sorts of weird and wonderful situations. I never use it.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor