dynamically generating a module

Peter Hansen peter at engcorp.com
Wed Nov 14 02:49:18 CET 2001


Hung Jung Lu wrote:
> 
> Here is one more challenge: is it possible to create a module on the
> fly?
> 
> Suppose I have the ASCII Python source code of a module-to-be, or even
> better, suppose that I have the compiled byte code of a module-to-be,
> stored in a Python string. Is there a simple way (meaning not tweaking
> at C++ level) of making the module-to-be into a real module, without
> hitting the harddrive?

You can use new.module() to get a "raw" module to play with.  

Example of one way to use it at 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82234

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list