I am learning Python and am still a beginner, although I have been studying it for about a year now. I am trying to write a module of functions which is called within a main
As others have said, there isn't actually a global pi
in your module1
. A good solution for you is this, which only imports pi
once from math
and explicitly ensures that the pi
you're getting is the one from module1
:
main.py
:
import module1
def wow():
print module1.pi
wow()
module1.cool()
module1.py
:
from math import pi
def cool():
print pi