Message357064
I think there is a same issue with "nargs='+'" - if you are aware of the, please ignore me.
$ python3 --version
Python 3.7.5
With "choices=...", there seems to be a problem:
$ cat bbb.py
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('choices', nargs='*',
default=['a', 'b', 'c'],
choices=['a', 'b', 'c'])
args = parser.parse_args()
print(args)
$ ./bbb.py
usage: bbb.py [-h] [{a,b,c} [{a,b,c} ...]]
bbb.py: error: argument choices: invalid choice: ['a', 'b', 'c'] (choose from 'a', 'b', 'c')
$ ./bbb.py a c
Namespace(choices=['a', 'c'])
but without choices it works:
$ cat bbb.py
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('choices', nargs='*',
default=['a', 'b', 'c'])
args = parser.parse_args()
print(args)
$ ./bbb.py
Namespace(choices=['a', 'b', 'c'])
$ ./bbb.py a c
Namespace(choices=['a', 'c'])
As I said, if this is a known issue, I'm sorry for the noise. |
|
Date |
User |
Action |
Args |
2019-11-20 11:55:54 | Jan Hutař | set | recipients:
+ Jan Hutař, rhettinger, bethard, macfreek, eric.smith, eric.araujo, ced, deleted250130, thesociable, regis, berker.peksag, paul.j3, sebix, lanzz |
2019-11-20 11:55:54 | Jan Hutař | set | messageid: <1574250954.15.0.923502030356.issue9625@roundup.psfhosted.org> |
2019-11-20 11:55:54 | Jan Hutař | link | issue9625 messages |
2019-11-20 11:55:53 | Jan Hutař | create | |
|