Chris Bruner added the comment:
Just had a chance to try this, and this does exactly what I wanted from
"type=". Thank you!
On Fri, Jul 25, 2014 at 4:17 PM, paul j3 wrote:
>
> paul j3 added the comment:
>
> What you want is a custom Action rather than a custom Type.
>
Chris Bruner added the comment:
Yes, I know. My function just sees '1', but I think it should see '1 2 3' so
that it can figure out what to do. That's impossible (well, impossible without
saving state between calls) when it sees the arguments piecemeal.
Sent from my
Chris Bruner added the comment:
Oops, my mistake: had multiple '-t' in file, but not an "action=append". Your
version works just fine.
Sorry for the confusion, and thank you for the correction!
--
___
Python tracker
<
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 argum
New submission from Chris Bruner:
When reading options from a file, argparse should read all values from
each line. Instead, it complains of there not being enough options.
python file:
#!/usr/bin/env python
import argparse
p = argparse.ArgumentParser(description='Reproduce argparse
New submission from Chris Bruner:
>From the documentation, I think that argparse should pass the entire
>nargs-long string to the "type=" callable. Instead, it only passes the first
>argument (of nargs), making it impossible within argparse's framework to check
>