Answer the question
In order to leave comments, you need to log in
Problem with python3 import?
Hello, there is a file structure:
-/dir_main/
----/INTERLAYER/
------__init__.py
------dependencies.py (here is the usual function def run_test() )
-/dir_main/
-- --/test/
------file_010.py (importlib) The
question is how to call the run_test() function from dependencies.py in file_010.py. Tried like this:
[__init__.py from INTERLAYER]
__all__ = ["run_test"]
[file_010.py]
interl = importlib.import_module("INTERLAYER")
interl.run_test(routine_n=["r1.py"], routine_p=[" bank"])
I get:
AttributeError("module 'INTERLAYER' has no attribute 'run_test'")
Answer the question
In order to leave comments, you need to log in
The issue is resolved, thanks to everyone (no),
- in the code [file_010.py] we write:
import importlib
dep = importlib.import_module("INTERLAYER")
dep.run_test()
- [__init.py__ (INTELAYER)]
from dependencies import *
- [dependencies.py]
def run_test():
...
After that file_010 will start seeing everything from dependencies.py
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question