Message154880
To me, "all positional parameters" mean whether they are in the front, back or middle, as long as they are not diriectly preceded by an option that can accept an unlimited number of parameters.
from argparse import ArgumentParser, SUPPRESS, REMAINDER
import sys
print( sys.version )
parser = ArgumentParser()
parser.add_argument('--foo', dest='foo')
parser.add_argument('--bar', dest='bar')
parser.add_argument('baz', nargs='*')
print( parser.parse_args('a b --foo x --bar 1 c d'.split()))
# expected: Namespace(bar='1', baz=['a', 'b', 'c', 'd'], foo='x')
# actual: error: unrecognized arguments: c d
Above also supplied as a test file, t12.py |
|
Date |
User |
Action |
Args |
2012-03-04 06:37:34 | v+python | set | recipients:
+ v+python |
2012-03-04 06:37:33 | v+python | set | messageid: <1330843053.88.0.983162018395.issue14191@psf.upfronthosting.co.za> |
2012-03-04 06:36:30 | v+python | link | issue14191 messages |
2012-03-04 06:36:30 | v+python | create | |
|