Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Roel Schroeven
Jon Ribbens via Python-list schreef op 3/08/2021 om 22:55: >> Loads of git commands do this. e.g. commit, diff, log, status, etc. >> It's not completely unlike what you're describing above, which is >> already supported automatically by argparse. > > Commands like git commit do not use '--' to se

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Jon Ribbens via Python-list
On 2021-08-03, Roel Schroeven wrote: > Jon Ribbens via Python-list schreef op 3/08/2021 om 17:48: >> On 2021-08-03, Michael Torrie wrote: >> > On 8/2/21 1:43 PM, Sven R. Kunze wrote: >> >> maybe, I am missing something here but is it possible to specify a >> >> delimiter for list arguments in ar

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Chris Angelico
On Wed, Aug 4, 2021 at 7:07 AM Sven R. Kunze wrote: > > It could be but I've seen them used somewhere else. > > I wouldn't bikeshed on this yet, as I haven't found a way to do this so > far. Let's imagine the following parser: > > parser.add_argument('things',action='append') > parser.add_argument

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Sven R. Kunze
It could be but I've seen them used somewhere else. I wouldn't bikeshed on this yet, as I haven't found a way to do this so far. Let's imagine the following parser: parser.add_argument('things',action='append') parser.add_argument('stuff',action='append') At least from my point of view, I don

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Roel Schroeven
Jon Ribbens via Python-list schreef op 3/08/2021 om 17:48: On 2021-08-03, Michael Torrie wrote: > On 8/2/21 1:43 PM, Sven R. Kunze wrote: >> maybe, I am missing something here but is it possible to specify a >> delimiter for list arguments in argparse: >> >> https://docs.python.org/3/library/a

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Jon Ribbens via Python-list
On 2021-08-03, Michael Torrie wrote: > On 8/2/21 1:43 PM, Sven R. Kunze wrote: >> maybe, I am missing something here but is it possible to specify a >> delimiter for list arguments in argparse: >> >> https://docs.python.org/3/library/argparse.html >> >> Usually, '--' is used to separate two lis

Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Michael Torrie
On 8/2/21 1:43 PM, Sven R. Kunze wrote: > Hi everyone, > > maybe, I am missing something here but is it possible to specify a > delimiter for list arguments in argparse: > > https://docs.python.org/3/library/argparse.html > > Usually, '--' is used to separate two lists (cf. git). I've not seen

Re: argparse: delimiter for argparse list arguments

2021-08-02 Thread Dan Stromberg
Isn't -- usually used to signal the end of options? On Mon, Aug 2, 2021 at 12:52 PM Sven R. Kunze wrote: > Hi everyone, > > maybe, I am missing something here but is it possible to specify a > delimiter for list arguments in argparse: > > https://docs.python.org/3/library/argparse.html > > Usual

argparse: delimiter for argparse list arguments

2021-08-02 Thread Sven R. Kunze
Hi everyone, maybe, I am missing something here but is it possible to specify a delimiter for list arguments in argparse: https://docs.python.org/3/library/argparse.html Usually, '--' is used to separate two lists (cf. git). Cheers, Sven -- https://mail.python.org/mailman/listinfo/python-li

Re: argparse list

2010-09-02 Thread Michele Simionato
On Sep 2, 1:45 pm, Neal Becker wrote: > I'm interested in using argparse to parse a string formatted as: > > my_prog --option1=1,10,37 > > That is, a list of comma delimited values.  I guess nargs almost does it, > but expects options to be space-delimited. > > What would be the easiest approach?

Re: argparse list

2010-09-02 Thread Peter Otten
Neal Becker wrote: > Peter Otten wrote: > > import argparse > def csv(value): >> ... return map(int, value.split(",")) >> ... > p = argparse.ArgumentParser() > p.add_argument("--option1", type=csv) and None > p.parse_args(["--option1=1,10,37"]) > > Thanks! But, why the '

Re: argparse list

2010-09-02 Thread Neal Becker
Peter Otten wrote: import argparse def csv(value): > ... return map(int, value.split(",")) > ... p = argparse.ArgumentParser() p.add_argument("--option1", type=csv) and None p.parse_args(["--option1=1,10,37"]) Thanks! But, why the 'and None'? -- http://mail.python.

Re: argparse list

2010-09-02 Thread Peter Otten
Neal Becker wrote: > I'm interested in using argparse to parse a string formatted as: > > my_prog --option1=1,10,37 > > That is, a list of comma delimited values. I guess nargs almost does it, > but expects options to be space-delimited. > > What would be the easiest approach? >>> import argp

argparse list

2010-09-02 Thread Neal Becker
I'm interested in using argparse to parse a string formatted as: my_prog --option1=1,10,37 That is, a list of comma delimited values. I guess nargs almost does it, but expects options to be space-delimited. What would be the easiest approach? -- http://mail.python.org/mailman/listinfo/python