replacement of rexec?

Evan Simpson evan at 4-am.com
Thu Oct 30 11:54:58 EST 2003


Skip Montanaro wrote:
>     >> You could use the new compiler module to parse and inspect the result
> 
>     Huaiyu> Thanks for the suggestion.  Is there existing code to assemble
>     Huaiyu> the parsed tree back to the intended Python object?
> 
> I'm not aware of anything.  Assuming your inspection process shows the file
> is okay, why not just call execfile()?

compiler.pycodegen and new.function or exec can be used to make a code 
object and execute it. As Skip says, though, this is pointless unless 
you are mutating the AST, as Zope's RestrictedPython package does.

Cheers,

Evan @ 4-am






More information about the Python-list mailing list