Command line arguments in Windows
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Command line arguments in Windows
> 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. argtest.py arg1 arg2 arg3 - Does not work only get sys.argv[0] python argtest.py arg1 arg2 arg3 - Works -- http://mail.python.org/mailman/listinfo/python-list
Re: Command line arguments in Windows
"Mark Tolonen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > From the command line, the 'ftype' and 'assoc' commands can be used > view how an extension is handled: > > C:\>assoc .py > .py=Python.File > > C:\>ftype Python.File > Python.File="C:\Python25\python.exe" "%1" %* > > My guess is your command line looks something like this: > > Python.File="C:\Python25\python.exe" "%1" > > The script name is being passed, but not the rest of the arguments. > I vaguely remember seeing this on an older version one of ActiveState's > ActivePython installers. What version of Python are you running? > > --Mark > Here is the output from the commands you listed which looks right to me. C:\>assoc .py .py=Python.File C:\>ftype python.file python.file="C:\Python25\python.exe" "%1" %* I am using Python 2.5.2 from http://www.python.org/ running on Windows Vista. Would ActiveState's version be a better choice here? ~Mike -- http://mail.python.org/mailman/listinfo/python-list