Skip to content

majerteam/stringimporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

import raw string as real Python modules

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages