python-include

Relative imports that actually work


License
MIT
Install
pip install python-include==2.0.0

Documentation

Install

pip install python-include

Use

import python_include

# import [name] from-anywhere (doesnt pollute global namespace)
hello = python_include.file("./path/to/file/with/hello/func/code.py", {"__file__":__file__}).hello
hello()

# import [*everything*] from-anywhere (does pollute global namespace)
python_include.file("./path/to/file/with/hello/func/code.py", globals())
hello() # function that was defined inside that^ "code.py"