Let's say I have a module like this:
```
# module1
def print_message(msg):
mw.message(msg)
```
Say also I have a second module which is a script. Inside of this script, I want to import module1 and use it in that module:
```
# my module
import module2
module2.print_message("hello mecway world!")
```
However an error occurs ("global name 'mw' is not defined") when importing module1, because the module1 globals() doesn't contain mw. Is there a way I can import the mw, solution, etc modules inside of my module1? I have already tried this:
import mw
But that doesn't work.
NOTE: I want to do things this way because there is a lot of code in module1.py that needs to be separated from module2.py, because it is being reused quite a bit.
Comments
A workaround is to add your own mw variable in the imported module from the importing module before using it, like this:
module1.py: main_script.py: