Message154880
| Author |
v+python |
| Recipients |
v+python |
| Date |
2012年03月04日.06:36:29 |
| SpamBayes Score |
2.8379796e-05 |
| Marked as misclassified |
No |
| Message-id |
<1330843053.88.0.983162018395.issue14191@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|
History
|
|---|
| 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 |
|