Ben Gartner Ben Gartner - 4 months ago 22x
Python Question

When running a python script in IDLE, is there a way to pass in command line arguments (args)?

I'm testing some python code that parses command line input. Is there a way to pass this input in through IDLE? Currently I'm saving in the IDLE editor and running from a command prompt.

I'm running Windows.


It doesn't seem like IDLE provides a way to do this through the GUI, but you could do something like: -r arg1 arg2 arg3

You can also set sys.argv manually, like:

    sys.argv = [sys.argv[0], 'argument1', 'argument2', 'argument2']