Reputation: 65
I'm getting a list out of range error from sys.argv[1] and I tried making a simple script with this code.
import sys
print sys.argv
I get this on cmd:
C:\...\...\...\py>back.py exampleargv
['C:\\...\\...\\...\\py\\back.py']
I don't know why I don't get the next arg.
Upvotes: 2
Views: 389
Reputation: 694
It's a windows specific problem: try "python back.py examplearg" and it will work.
Solution (besides not running Windows!) is to update your registry.
http://eli.thegreenplace.net/2010/12/14/problem-passing-arguments-to-python-scripts-on-windows/
Set these keys = value
HKEY_CLASSES_ROOT\Applications\python26.exe\shell\open\command = "C:\Python26\python26.exe" "%1" %*
HKEY_CLASSES_ROOT\py_auto_file\shell\open\command = "C:\Python26\python26.exe" "%1" %*
Upvotes: 5