comments on runpy module

Alexey Luchko luch at ank-sia.com
Fri Sep 23 20:38:36 CEST 2011


> Example script.py: """
> def f(arg):
>     return g(arg)
>
> def g(arg):
>     return arg
> """

> Reading the Lib/runpy.py I've found, that the temporary module created
> inside the run_path() calls, is destroyed right after the script.py code
> executed in the resulting namespace.

I've got an idea.  It would be nice if there existed such a way to use it:
with runpy.run_path("script.py") as a_namespace:
   a_namespace["f"]("abc")

--
Regards,
Alex.



More information about the Python-list mailing list