python3 - Import python file as module
I am a beginner to Python. I want to achieve the following:
My directory structure:
??? ??? q
??? ??? test.py
In my run.py file, I want to import everything from test.py(contains methods).
I have found relative path for test.py as "....p.q".
I tried with exec() to import as : exec("from ....p.q import *"),
but this gives me >> "list out of index" error.
Then I tried with importlib.import_module with various combinations such as:
1. importlib.import_module('.test', package="....p.q")
2. importlib.import_module('test', package="....p.q")
3. importlib.import_module('....p.q.test', package=None)
But I end up getting error as >> No module found "".
Can anyone help me with this situation?
Any help will be appreciated!
CONFIDENTIALITY. This email and any attachments?are?confidential?to Alef
Edge Inc., and may also be privileged,?except?where the?email?states it can
be disclosed.?If this email?is received in?error, please?do not disclose
the contents?to anyone, notify?the sender by return?email, and delete?this
email (and any?attachments) from your system.