I'm not sure if this is exactly what you want, but there's an exec
command that takes a file object and interprets it as a python script.
I think there are also variants that take a file name, and there might
also be variants to run the file in a sandbox.
--Mike