Command Line arguments

michael savvyside at aol.com
Thu Aug 25 12:46:41 CEST 2005


On Thu, 25 Aug 2005 00:46:41 -0700, Tim Roberts wrote:

> michael <savvyside at aol.com> wrote:
> 
>>I have a question about Windows based python (2.4 and later).
>>
>>For example, if I make a script called test.py like so:
>>
>>import sys
>>print sys.argv
>>
>>then run it:
>>
>>python test.py this is a test
>>
>>I see a list with 
>>
>>['test.py', 'this', 'is', 'a', 'test']
>>
>>
>>All is good!
>>
>>BUT...
>>
>>If i make .py extensions be run as exes (by setting the .py extension to
>>be executable with PATHEXT setting in environment variables, the Python
>>program will run, but NO arguments are passed!
>>
>>For example, after setting .py extension to be executable, i get this:
>>
>>test this is a test
>>
>>I get ['test.py]. NO arguments are passed. 
>>
>>NOTE: This can NOT be blamed on Windows in my mind because Python2.2 and
>>earlier works FINE.
> 
> It is a configuration problem.  Bring up a Command Shell and run the assoc
> and ftype commands like this:
> 
>   C:\Tmp>assoc .py
>   .py=Python.File
> 
>   C:\Tmp>ftype Python.File
>   Python.File="C:\Apps\Python24\python.exe" "%1" %*
> 
>   C:\Tmp>
> 
> The KEY part of that is the %* at the end of the Python.File defintion.
> That tells the system to insert the rest of the command line parameters at
> that point.  If you have ONLY the "%1", the command will run but no
> parameters will be forwarded.  If so, you can fix this by typing:
> 
>   C:\Tmp>ftype Python.File="C:\Apps\Python24\python.exe" "%1" %*
> 
> Substituting your own path, of course.



SOLVED! Thank you.

I wonder why this was needed for 2.4 and not 2.2? I don't think it was
lingering things from old installs because it happened on a persons
computer that had never had any python installed before 2.4.

Anyway, THANKS!

Michael 




More information about the Python-list mailing list