dynamically generating a module

Richard Jones richard at bizarsoftware.com.au
Tue Nov 13 18:25:43 EST 2001


On Wednesday 14 November 2001 09:59, Hung Jung Lu wrote:
> Hi,
>
> Python does have good dynamic features. You can add/remove objects,
> classes, methods, etc. dynamically.
>
> 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?

Absolutely - look in the imp module.


   Richard




More information about the Python-list mailing list