Open
Description
From here: https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path
we can actually import module files from a full python path. Since here()
will return a full path, we can write a function that makes it easier to import.
I don't want to name the function import
, but something like:
import pyprojroot
# will append `src` to the import path (temporarily)
pyprojroot. proj_import(here("./src"))`
import my_module1
import my_module2
# will import module directly, given a .py script
pyprojroot. proj_import(here("./src/my_module.py"))`
Metadata
Metadata
Assignees
Labels
No labels