I'm obviously in need of help with argparse. From the 3.4 manual, if I type
import argparse
parser = argparse.ArgumentParser(prog='PROG')
parser.add_argument('-f', '--foo')
parser.add_argument('bar')
parser.parse_args()
on the command line, having saved this code into test.py and then run
test.py bar
I as expecting my prompt back, but I get
usage: PROG [-h] [-f FOO] bar
PROG: error: the following arguments are required: bar
What have I got to do to make test.py accept a non-optional argument? Incidentally, I'm running this on Windows 8.1, and when I run the same code on my Mac, I get my prompt back with no script output as expected. That means it's something to do with windows.
EDIT: I can try this in an interactive session and it also fails to operate correctly.
EDIT: Yes - sys.argv is not having the arguments appended to it. I think it's something to do with the file association. On install, Parallels uses Python's Python Launcher which mean it tried to run the script on my Mac host. I edited the association to the local python binary, but now this. I've tried hacking the registry to help, but it was already set correctly to "c:\windows\py.exe" "%1" %*