Skip to main content
Help us improve Python packaging – donate today!

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.

Release history Release notifications

This version
History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
stringimporter-0.1.4-py2.py3-none-any.whl (2.7 kB) Copy SHA256 hash SHA256 Wheel 3.5 Jun 6, 2016
stringimporter-0.1.4.tar.gz (1.8 kB) Copy SHA256 hash SHA256 Source None Jun 6, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page