Skip to main content

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


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)

Uploaded Source

Built Distribution

stringimporter-0.1.4-py2.py3-none-any.whl (2.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file stringimporter-0.1.4.tar.gz.

File metadata

File hashes

Hashes for stringimporter-0.1.4.tar.gz
Algorithm Hash digest
SHA256 339306b012ac77046c93b7dcfd93ce84dc3f47cfce645dec87fd7316f32e75a7
MD5 e22214dbaffda37f11a001992577ef18
BLAKE2b-256 07de27ef935a2b63c68755c22acc463a50b9cea6c500cc8d20a3fe7e46a441bf

See more details on using hashes here.

File details

Details for the file stringimporter-0.1.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for stringimporter-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1a0e6f54ba3e334d733776f0f7fb1d24c449fb56514fe0690cb211150a124706
MD5 4d78ab9db25d44173405f998a0f88227
BLAKE2b-256 b382f8b6e0f54fa086bd22edebff32b5262aa43436dd3f3616bb72e5c7543535

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page