You have a circular import:
myInt
andmyFunction
have not yet been assigned to when theimport mymodule.myfile
is run.mymodule.myfile
then tries to import the names that are not yet assigned to frommymodule
.
Your options are to move myInt
and myFunction
to a separate shared module:
mymodule/
__init__.py
myfile.py
utilities.py
where __init__.py
imports from both mymodule.myfile
and mymodule.utilities
, and myfile.py
imports from mymodule.utilities
.
Or you can import just the module in myfile.py
and defer referencing the myInt
and myFunction
names until later (in a function call, for example):
import mymodule
def somefunction():
mymodule.myFunction(mymodule.myInt)
By the time somefunction()
is called all imports have completed and mymodule.myFunction
and mymodule.myInt
have been assigned to.