Import without a .py file

William Park parkw at better.net
Thu May 11 22:07:20 EDT 2000


On Fri, May 12, 2000 at 01:03:55AM +0000, Michael Ross wrote:
> 
> I would like to accomplish the equivalent of an import, but store module
> code in a database (rather than in .py files).
> 
> Is there any way to create a module using code that did not originate in
> a file?  For example, I can get the text for the code into a string
> object, and then I'd like to say
> 
> s = ...string containing code with classes and functions...
> import module using s
> 
> obviously I can't do that, but something equivalent would be nice.
> 
> 
> Thanks!
> Mike Ross

exec(s)

--William




More information about the Python-list mailing list