[issue22050] argparse: read nargs > 1 options from file doesn't work

Chris Bruner report at bugs.python.org
Wed Jul 23 20:47:18 CEST 2014


Chris Bruner added the comment:

Tried the format you gave. Still doesn't work. Same error message:

bernoulli:myclu cwbrune$ argparse_nargs_file_bug.py 
usage: argparse_nargs_file_bug.py [-h] [-t N N N]
argparse_nargs_file_bug.py: error: argument -t/--triple: expected 3 argument(s)
bernoulli:myclu cwbrune$ cat argparse_nargs_file_bug.py 
#!/usr/bin/env python
import argparse

p = argparse.ArgumentParser(description='Reproduce argparse nargs file bug',
    fromfile_prefix_chars='@')
p.add_argument('-t', '--triple', metavar='N', nargs=3)

args = p.parse_args(['@input.opts'])
print args
bernoulli:myclu cwbrune$ cat input.opts 
--triple 
1 
2 
3
-t 
2 
2 
32
bernoulli:myclu cwbrune$

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22050>
_______________________________________


More information about the Python-bugs-list mailing list