How to pass an argument to a python program open in IDLE?
Fredrik Lundh
fredrik at pythonware.com
Fri Nov 17 10:25:02 EST 2006
"TonyHa" wrote:
> My problem is this: When I start IDLE GUI, then I open my script with
> the edit window. (i.e.
> File -> open). I run my script under the edit window using run -> run
> module or F5. But IDLE does not allow me to input the argument to my
> script, i.e. IDLE runs without prompting for the argument, then my
> script fails. I wonder how can I pass the argument to my script under
> IDLE?
one would think that there would be a "set argument" command somewhere, but I
sure couldn't find it.
as a workaround, to help with testing, you can simply do:
import sys
if not sys.argv[1:]:
sys.argv += ["argument1", "argument2", "argument3"]
at the top of your program.
</F>
More information about the Python-list
mailing list