Nov-07-2018, 06:44 PM
I'm trying to create modules for my application that are themselves testable on their own. I would like to have the following directory structure:
\application.py
\support\module1.py
\support\module2.py
application.py depends on both module1.py and module2.py.
module1.py is also dependent directly on module2.py
My way to make this work so far is the following in module1.py
Without that, I get various "module not found" issues. I did a lot of reading on absolute and relative imports, but I can't identify my case among the many examples presented. My alternative plan was to leave everything flat for now (no directories) so that imports are nice and straightforward. But for a larger application, I know this would just make a big mess.
Ideas?
\application.py
\support\module1.py
\support\module2.py
application.py depends on both module1.py and module2.py.
module1.py is also dependent directly on module2.py
My way to make this work so far is the following in module1.py
1 2 3 4 |
if __name__ = = "__main__" : import module2 else : import support.module2 |
Ideas?