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 details)
Built Distribution
File details
Details for the file stringimporter-0.1.4.tar.gz
.
File metadata
- Download URL: stringimporter-0.1.4.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 339306b012ac77046c93b7dcfd93ce84dc3f47cfce645dec87fd7316f32e75a7 |
|
MD5 | e22214dbaffda37f11a001992577ef18 |
|
BLAKE2b-256 | 07de27ef935a2b63c68755c22acc463a50b9cea6c500cc8d20a3fe7e46a441bf |
File details
Details for the file stringimporter-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: stringimporter-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a0e6f54ba3e334d733776f0f7fb1d24c449fb56514fe0690cb211150a124706 |
|
MD5 | 4d78ab9db25d44173405f998a0f88227 |
|
BLAKE2b-256 | b382f8b6e0f54fa086bd22edebff32b5262aa43436dd3f3616bb72e5c7543535 |