Arbitrary import Python source as a Python module
Project description
stringimporter
stringimporter lets you import raw string as real Python modules
How to use
You can read the tests (in tests directory) or copy the following code.
import stringimporter
module_from_thin_air = """
def multiply_by_2():
return lambda x: 2*x"""
loader, mymodule = stringimporter.import_str('yihaaa', module_from_thin_air)
hello_2 = mymodule.multiply_by_2()("hello ")
Dependances
None
Compatibility
Python 3. I don’t know (yet?) how to emulate importlib.abc.SourceLoader on Python 2.7.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stringimporter-0.1.4.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for stringimporter-0.1.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a0e6f54ba3e334d733776f0f7fb1d24c449fb56514fe0690cb211150a124706 |
|
MD5 | 4d78ab9db25d44173405f998a0f88227 |
|
BLAKE2b-256 | b382f8b6e0f54fa086bd22edebff32b5262aa43436dd3f3616bb72e5c7543535 |