I am creating a functional "component" which has the following structure right now:
from config_file import *
def FunctionalComponent():
foo(a_from_config)
bar(b_from_config)
...
but want to convert it into something like
def functional_component(module_file):
<do something with `module_file` which imports all the variables>
foo(a_from_config)
bar(b_from_config)
...
which can be called by the end user as
functional_component(module_file = "path_to_config_file.py")
but am not able to find a good way to do so. I tried using
def FunctionalComponent(module_file):
from module_file import a_from_config
print(a_from_config)
and calling it as (i wasn't sure how to pass the string (path to file) and import it, so tried passing the imported module itself. For the final function, passing a path(string) as a parameter is needed)
import module_file
FunctionalComponent(module_file)
but that gave ModuleNotFoundError: No module named 'module_file'
Any advice would be highly appreciated, thanks :)