Skip to main content

Arbitrary import Python source as a Python module

Project description

stringimporter

let’s 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 ")

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.2.tar.gz (1.6 kB view hashes)

Uploaded Source

Built Distribution

stringimporter-0.1.2-py2.py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 2 Python 3

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