How to run script from interpreter?

Fredrik Lundh fredrik at effbot.org
Fri Jan 19 12:52:56 EST 2001


Dan Rolander wrote:
> One more thing, is there a way to pass a command line parameter to the
> script named in execfile? Say if I have a script to test which expects a
> value in sys.argv[1]?

did you try putting it in sys.argv[1] ?

import sys
sys.argv = ["spam.py", "one", "two", "three"]
execfile("spam.py")

Cheers /F





More information about the Python-list mailing list