thesmuggler

Sidestep import and load Python files as relative paths


Keywords
import, modules, packages, files
License
MIT
Install
pip install thesmuggler==1.0.0

Documentation

The Smuggler 🚬

Build Status Smuggler on PyPI

Sidestep import and load Python files as relative paths.

Intended for one-off imports (e.g. global configuration). Currently, thesmuggler can't import files that import other local packages, but you can thesmuggle files that have already smuggled other files.

Tested and working on Python 2.7 and up.

Usage

pip install thesmuggler, then:

from thesmuggler import smuggle

# À la `import weapons`
weapons = smuggle('weapons.py')

# À la `from contraband import drugs, alcohol`
drugs, alcohol = smuggle('drugs', 'alcohol', source='contraband.py')

# À la `from contraband import drugs as dope, alcohol as booze`
dope, booze = smuggle('drugs', 'alcohol', source='contraband.py')