Command line arguments in Windows

Steve Holden steve at
Tue Mar 4 12:51:25 CET 2008

Chris wrote:
> On Mar 4, 8:38 am, "Mike Walker" <mhwal... at> wrote:
>>> If you run a python file, ie. just double clicking it the only
>>> argument you will have will be the filename of the script.  If you
>>> create a shortcut to the script and in the target box add your
>>> arguments (if you have quotation marks place them after not inside)
>>> you will see your arguments.  fwiw you answered yourself in the third
>>> paragraph.
>> As I mentioned I am working from the command line, not clicking on the icon.
>> The only difference between it working and not is the python prefix, which
>> is why I was thinking this is some sort of file association problem.
>> I probably wasn't as clear as I could have been in the third paragraph.
>> arg1 arg2 arg3 - Does not work only get sys.argv[0]
>> python arg1 arg2 arg3 - Works
> That seems rather wierd, just running arg1 arg2 arg3 I get
> the correct output, Python 2.5.1 from but running on XP
> though.  Potentially an issue with Vista... ?

Strange as it may seem, there have been issues with other Windows 
command processors, and one in particular (I can never remember which 
one) messes up IO redirection when the pathext mechanism is used to 
select the executable that processes the Python file.

So I would tend to suspect yet another variation on this familiar theme 
given your testing results. But I don't intend to tangle with Vaster any 
sooner than I must.

Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC    

More information about the Python-list mailing list