Command line arguments in Windows

Mike Walker mhwalker at shaw.ca
Tue Mar 4 00:12:39 EST 2008


I am having some problems with command line arguments in Windows. The same 
code under Linux works fine.

In Windows I only get one argument no matter how many arguments are passed 
on the command line. I think there is some problem with the way the .py 
files are associated causing this. I'm just not sure how to go about fixing 
it.

If I call the python script using the command "python argtest.py arg1 arg2 
etc..." this also works fine. Its only when run the program using the name 
only that the problem occurs.

Does anyone have any ideas what the problem is here and hopefully how to go 
about fixing it?

import sys

if __name__ == "__main__":
    for arg in sys.argv:
        print arg 




More information about the Python-list mailing list