Message262545
In Python 3.5, this does not seem fixed. Issue 13922 is marked as resolved and fixed, but Pauls’s patch has not actually been committed.
>>> ap = ArgumentParser()
>>> ap.add_argument("-t", "--test", type=str, nargs=1)
_StoreAction(option_strings=['-t', '--test'], dest='test', nargs=1, const=None, default=None, type=<class 'str'>, choices=None, help=None, metavar=None)
>>> ap.add_argument('yuri', nargs='?')
_StoreAction(option_strings=[], dest='yuri', nargs='?', const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> ap.parse_args(["--test=--", "foo"])
Namespace(test=[], yuri='foo')
>>> ap.parse_args(["--test", "--", "foo"])
usage: [-h] [-t TEST] [yuri]
: error: argument -t/--test: expected 1 argument
argparse.ArgumentError: argument -t/--test: expected 1 argument
During handling of the above exception, another exception occurred:
__main__.SystemExit: 2
>>> ap.parse_args(["-t--", "foo"])
Namespace(test=[], yuri='foo')
>>> ap.parse_args(["-t", "--", "foo"])
usage: [-h] [-t TEST] [yuri]
: error: argument -t/--test: expected 1 argument
argparse.ArgumentError: argument -t/--test: expected 1 argument
During handling of the above exception, another exception occurred:
__main__.SystemExit: 2 |
|
Date |
User |
Action |
Args |
2016-03-28 01:49:32 | martin.panter | set | recipients:
+ martin.panter, bethard, eric.araujo, r.david.murray, maker, paul.j3 |
2016-03-28 01:49:32 | martin.panter | set | messageid: <1459129772.52.0.352628151213.issue14364@psf.upfronthosting.co.za> |
2016-03-28 01:49:32 | martin.panter | link | issue14364 messages |
2016-03-28 01:49:31 | martin.panter | create | |
|