in py_script.py:
import os
import sys
l = len(sys.argv)
if l == 1:
print 'no args'
else:
if l > 1:
print 'first arg is %s'%sys.argv[1]
if l > 2:
print 'second arg is %s'%sys.argv[2]
now going command-line, on my winXP platform:
d:\path\py_script.py 1 2
yields
first arg is 1
second arg is 2
yet on my Win7 platform I get
no args
If I do
d:\path\python py_script.py 1 2
I get
first arg is 1
second arg is 2
How can I make my Win7 environment act as expected ?
some details:
win7 is 64bit.
py2.6.6 on win7, py 2.6.4 on winXP.
I know this doesn't answer your question, but
python py_script.py
is the standard way to execute Python scripts.I'm using 2.7.1 on Win 7.
If you want to invoke Python programs by file extension alone, you should check the file type associations and command line parameters. I have experienced issues when installing/reinstalling multiple versions of Python on Windows.
This TechNet page can provide some more detailed background.
http://technet.microsoft.com/en-us/library/bb490912.aspx
Based on jtp's answer.
Well I messed up with the registry a bit.
This was what I think are the steps:
doing
assoc .py=Python.File
through win explorer pick a .py file, right click -> x64 -> open with > browse to c:\Python26\python.exe choose the 'always open with this..' box. this in effect changes immediately the reg value
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.py\UserChoice
to
Python.File
note: from previous experience i'm sure things are expected to mess up with mixed versions. uninstalling/re-installing shall be the way to go. BTW, I didn't want to go through that becuase with all the packages including ones I built from source it would be a mess.