Golang style imports in python
import-module is a python package which allows to import packages as in golang. Currently it supports modules from github.com, bitbucket.org, git.launchpad.net, and pypi.python.org.
Importing a module (with
statement must be used):
from import_module import ImportModule
with ImportModule("github.com/i96751414/py-dummy"):
import dummy
print("The output of dummy.call is '{}'".format(dummy.call()))
Output:
The output of dummy.call is 'call'
-
ImportModule(module, path=None, reload_module=False, use_pip=False)
Import the specified module. If the module already exists and
reload_module
is True, then re-import the module. Ifpath
is given, the module will be imported to the given path. Ifuse_pip
is True, the module will be imported with pip, even if it is a git repository.