[issue22049] argparse: type=<callable> doesn't honor nargs > 1

Chris Bruner report at bugs.python.org
Fri Jul 25 19:29:46 CEST 2014


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 iPhone

> On Jul 24, 2014, at 9:42 PM, paul j3 <report at bugs.python.org> wrote:
> 
> 
> paul j3 added the comment:
> 
> Note that 
> 
>    '-t 1 2 3'.split()
> 
> becomes
> 
>    ['-t', '1', '2', '3']
> 
> Your 'type' function sees those 3 strings individually.  Try printing 'string' the first thing in your function to see what we mean.
> 
> ----------
> nosy: +paul.j3
> 
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue22049>
> _______________________________________

----------

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


More information about the Python-bugs-list mailing list