Command Line Inputs from Windows

Chris Angelico rosuav at gmail.com
Fri Jan 2 16:29:05 EST 2015


On Sat, Jan 3, 2015 at 6:44 AM, Ken Stewart <gordon_ken_stewart at msn.com> wrote:
> This works:
> python myScript.py arg1 arg2 arg3
>
> This doesn’t work:
> myScript.py arg1 arg2 arg3

The latter form is governed by the association. I don't know off-hand
where that's set in the registry, but you should be able to poke
around in folder settings to find it (but, thank you very much
Microsoft, the exact menu path has changed a number of times between
Win2K and Win8). On WinXP, if I have my test-box set up correctly,
it's View, Folder Options, File Types, select the one for .py,
Advanced, select "open", Edit. That'll tell you that the application
used is something like:

"C:\Python27\python.exe" "%1" %*

The %* should mean that arguments get carried through; if that's
missing, you won't get any args.

I may have some details wrong, and it's likely to be a little
different on Win7, but poke around and look for a missing %*. Or,
better still, make sure you have the py.exe launcher; then you can
have Python scripts request a specific interpreter using a PEP 397
compliant shebang, which will also work nicely on Unix systems.

ChrisA



More information about the Python-list mailing list