https://github.com/fny/thesmuggler
Sidestep import and load Python files as relative paths
https://github.com/fny/thesmuggler
Last synced: about 1 year ago
JSON representation
Sidestep import and load Python files as relative paths
- Host: GitHub
- URL: https://github.com/fny/thesmuggler
- Owner: fny
- License: mit
- Created: 2017-10-11T19:10:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-20T15:48:42.000Z (over 2 years ago)
- Last Synced: 2025-03-25T03:51:13.974Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
The Smuggler 🚬
===============
.. image:: https://travis-ci.org/fny/thesmuggler.svg?branch=master
:target: https://travis-ci.org/fny/thesmuggler
:alt: Build Status
.. image:: https://badge.fury.io/py/thesmuggler.svg
:target: https://pypi.python.org/pypi/thesmuggler
:alt: Smuggler on PyPI
Sidestep :code:`import` and load Python files as relative paths.
Intended for one-off imports (e.g. global configuration). Currently, :code:`thesmuggler` can't import files that import other local packages, but you can :code:`smuggle` files that
have already smuggled other files.
Tested and working on Python 2.7 and up.
Usage
-----
:code:`pip install thesmuggler`, then:
.. code:: python
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')