Suppose I have a python module called mymodule
. At the top of my Code, I have this:
import mymodule
reload(mymodule)
where my directory structure is
/dir/mymodule.py
However, I would like to split mymodule.py
into several files, while still being defined as a single module (i.e. I don't want to have to import each file separately - I want to be able to use my import/reload as before).
The only way I know how to do this is the following
/dir/mymodule/
file1.py
file2.py
__init__.py
where __init__.py
contains
from file1 import *
from file2 import *
This mostly works, but my call to reload(mymodule)
no longer does anything, because it doesn't reload anything called via * imports.
Any suggestions?