Importing a String as a Module

bmatt bsmatt at gmail.com
Sun Sep 19 14:17:52 EDT 2004


Hello All,

I would like to import an internal string as a module into the python
interpreter. Unfortunately it looks like all of the PyImport functions
only take a module name and load the module from the .py file. Is
there a way to import a module from a string (similar to the way the
PyRun_String function works)? I have tried to use the PyRun_String
function and then use PyImport_AddModule but it doesn't look like  the
things defined in the string are in the module dictionary.

Thanks



More information about the Python-list mailing list