main.py:
from module1 import some_function
x=10
some_function()
module1.py:
def some_function():print str(x)
When I execute the main.py
, it gives an error in the moduel1.py indicating that x is not available.
My understanding was that using from x import y
in module main.py
brings the definition/value of x.y in the local namespace of main.py. And since both the function definition and variable x are in local namespace of main.py, it should work ok. But this seems incorrct undersyanding. So what is the exact concept here? Any link to officcial python documentation for this concept?