Supposing, I have a python module called mymodule
, it has the following structure:
""" mymodule.py """
mydata = {
"x": 12,
"y": 58
}
I want to access to data in the following way:
""" main.py """
import mymodule
print(mymodule.x) # 12
print(mymodule.y) # 58
What should I add to mymodule.py
?
I would like to know solutions for Python 2.7
and Python 3
.