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.
解决方案
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
set HKEY_CLASSES_ROOT\Python.File\shell\Open\Command to
"C:\Python26\python.exe" "%1" %2 %3 %4 %5 %6 %7 %8 %9
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.