Python has a nice execfile function inside the interpreter where you can run a program, keep all the variables in scope, and then inspect them at your leisure. However, as far as I know you can’t run execfile on a program that takes arguments from the command line; if you try to include the arguments, Python throws an IOError and complains that the file (with spaces and arguments) can’t be found.
Is there any way to run a Python script that takes command line arguments, and keep all of the variables in scope after the program executes? Like an execfile that takes flags?
Thanks,
Kevin
You could modify
sys.argvdirectly. The file:The other file:
Output:
But I must say, quoting Ignacio Vazquez-Abrams:
I’m assuming you have your reasons though.