I have two files. main.py that has main program logic and functions.py that has additional functions. Lets say main.py has this code
import functions
some_var = 'some value'
I would like to print out value of some_var in my functions.py file. How can I achieve this.
In general, you can do this my simply importing the
mainmodule withinfunctions.pyWithin your functions.py file:
However, you currently have a circular dependency problem. See Circular (or cyclic) imports in Python
You could put
some_varinto a third module, let’s sayconstants.pyand thenmain.pywould look like:and
functions.pywould be:Solving your circular dependency problem.