Yeah, I have been hearing that people are having troubles converting, but I
have only used argparse - got lucky there I guess.
I am thinking just making the function which spits the class out. Maybe not
very optimised solution, but simple.
Argument parsing in my case is very far from being a bo
On 11/27/23 13:21, Dom Grigonis wrote:
Thank you, exactly what I was looking for!
One more question following this. Is there a way to have a customisable action?
I.e. What if I want to join with space in one case and with coma in another. Is
there a way to reuse the same action class?
I've w
Thank you, exactly what I was looking for!
One more question following this. Is there a way to have a customisable action?
I.e. What if I want to join with space in one case and with coma in another. Is
there a way to reuse the same action class?
Regards,
DG
> On 27 Nov 2023, at 21:55, Mats Wi
On 11/27/23 04:29, Dom Grigonis via Python-list wrote:
Hi all,
I have a situation, maybe someone can give some insight.
Say I want to have input which is comma separated array (e.g.
paths='path1,path2,path3') and convert it to the desired output - list:
import argparse
parser = argparse.Argume
On Mon, 27 Nov 2023 at 22:31, Dom Grigonis via Python-list
wrote:
>
> Hi all,
>
> I have a situation, maybe someone can give some insight.
>
> Say I want to have input which is comma separated array (e.g.
> paths='path1,path2,path3') and convert it to the desired output - list:
This is a single
On Tue, 29 Nov 2022 at 12:37, Loris Bennett wrote:
>
> Mats Wichmann writes:
>
> > On 11/27/22 16:40, Skip Montanaro wrote:
> >> I have a script to which I'd like to add a --version flag. It should print
> >> the version number then exit, much in the same way --help prints the help
> >> text then
On Sun, 27 Nov 2022 22:23:16 -0600, Karen Park declaimed
the following:
>I figured it out…there was a logistics file given with the assignment! I
>thought it was supposed to be a download included with the python
>download…oops!
>
I think you made this response in the wrong thread...
Mats Wichmann writes:
> On 11/27/22 16:40, Skip Montanaro wrote:
>> I have a script to which I'd like to add a --version flag. It should print
>> the version number then exit, much in the same way --help prints the help
>> text then exits. I haven't been able to figure that out. I always get a
>>
Thanks. It occurs to me that instead of providing two special actions
("help" and "version"), it might be worthwhile to provide a standard way of
saying, "if present, process this option and exit before considering other
details of the command line." Matt's example action works well enough for
my n
hon-list on
behalf of Weatherby,Gerard
Date: Sunday, November 27, 2022 at 10:29 PM
To: Skip Montanaro , Python
Subject: Re: argparse — adding a --version flag in the face of positional args
Use two parsers:
import argparse
import sys
vparser = argparse.ArgumentParser(add_help=False)
vparser.add
I figured it out…there was a logistics file given with the assignment! I
thought it was supposed to be a download included with the python download…oops!
Thanks,
Karen
> On Nov 27, 2022, at 9:34 PM, Skip Montanaro wrote:
>
>
>>
>>
>> ummm, hate to say this, but have you checked the docu
>
> ummm, hate to say this, but have you checked the documentation? this
> case is supported using an action named 'version' without doing very much.
>
Thanks, Mats.
I actually searched all over the argparse docs. (There's a lot to digest.
Honestly, if I wasn't attempting to be sort of up-to-dat
Use two parsers:
import argparse
import sys
vparser = argparse.ArgumentParser(add_help=False)
vparser.add_argument('--version',action="store_true",help="show version")
# look for version, ignore remaining arguments
vargs, _ = vparser.parse_known_args()
if vargs.version:
print("Version 2.0")
On 11/27/22 16:40, Skip Montanaro wrote:
I have a script to which I'd like to add a --version flag. It should print
the version number then exit, much in the same way --help prints the help
text then exits. I haven't been able to figure that out. I always get a
complaint about the required positi
> class VersionAction(argparse.Action):
> def __call__(self, parser, namespace, values, option_string):
> print(VERSION)
> exit()
...
> parser.add_argument("-v", "--version", nargs=0, action=VersionAction)
Thanks. An action class didn't occur to me. I looked briefly at the
code
I wondered whether subparsers might work, but they don't quite fit here.
This seems to fit the bill fairly well, though I agree it would be
nice if there were a neater option:
import argparse
import sys
VERSION = 0.1
def main(args):
parser.parse_args(args)
class VersionAction(argparse.Act
On Thu, 23 Jun 2022 17:01:42 -0600, Mats Wichmann
declaimed the following:
>Assuming: that the "value" in your init method signature was supposed to
>be 'name' since that's what you use later - and would explain your
>exception!
>
Since it is a "named int", I'd expect value to the intege
Thanks a lot.
I will read documentation of enum module
בתאריך יום ו׳, 24 ביוני 2022, 14:33, מאת Roel Schroeven <
r...@roelschroeven.net>:
> Op 24/06/2022 om 0:32 schreef Dennis Lee Bieber:
> > On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer"
> > declaimed the following:
> >
> > >??? wrot
Op 24/06/2022 om 0:32 schreef Dennis Lee Bieber:
On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer"
declaimed the following:
>??? wrote at 2022-6-23 15:31 +0300:
>>how to solve this (argparse)
>>MAXREPEAT = _NamedIntConstant(32,name=str(32))
>>TypeError: 'name' is an invalid keyword a
נתי שטרן wrote at 2022-6-24 08:28 +0300:
>I copied code from argparse library and modified it
>
>בתאריך יום חמישי, 23 ביוני 2022, מאת Dieter Maurer :
>
>> נתי שטרן wrote at 2022-6-23 15:31 +0300:
>> >how to solve this (argparse)
>> >
>> >
>> >traceback:
>> >Traceback (most recent call last):
>> >
I copied code from argparse library and modified it
בתאריך יום חמישי, 23 ביוני 2022, מאת Dieter Maurer :
> נתי שטרן wrote at 2022-6-23 15:31 +0300:
> >how to solve this (argparse)
> >
> >
> >traceback:
> >Traceback (most recent call last):
> > File "u:\oracle\RTR.py", line 10, in
> >class s
On Fri, 24 Jun 2022 at 09:03, Mats Wichmann wrote:
> Also note that while it's claimed to be fine These Days, inheriting from
> a base type like this is sometimes tricky, sometimes broken... be
> somewhat aware.
Depends on your definition of "broken". If you want to make a custom
integer type, yo
On 6/23/22 16:32, Dennis Lee Bieber wrote:
> On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer"
> declaimed the following:
>
>> ??? wrote at 2022-6-23 15:31 +0300:
>>> how to solve this (argparse)
>
>>>MAXREPEAT = _NamedIntConstant(32,name=str(32))
>>> TypeError: 'name' is an invalid k
On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer"
declaimed the following:
>??? wrote at 2022-6-23 15:31 +0300:
>>how to solve this (argparse)
>>MAXREPEAT = _NamedIntConstant(32,name=str(32))
>>TypeError: 'name' is an invalid keyword argument for int()
>
>This does not look like an `a
נתי שטרן wrote at 2022-6-23 15:31 +0300:
>how to solve this (argparse)
>
>
>traceback:
>Traceback (most recent call last):
> File "u:\oracle\RTR.py", line 10, in
>class sre_constants():
> File "u:\oracle\RTR.py", line 77, in sre_constants
>MAXREPEAT = _NamedIntConstant(32,name=str(32))
>
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
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
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
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
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
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
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
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
On Fri, Jul 23, 2021 at 5:34 PM Albert-Jan Roskam
wrote:
>
> >>> [1] https://pypi.org/project/clize/
>
>
> I use and like docopt (https://github.com/docopt/docopt). Is clize a better
> choice?
>
Not necessarily. Both are good. Explore both, see which one makes more sense.
ChrisA
--
https://mai
>>> [1] https://pypi.org/project/clize/
I use and like docopt (https://github.com/docopt/docopt). Is clize a
better choice?
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, Jul 15, 2021 at 2:57 PM Dan Stromberg wrote:
>
>
> On Mon, Jul 12, 2021 at 12:34 PM Chris Angelico wrote:
>>
>> On Tue, Jul 13, 2021 at 5:22 AM lucas wrote:
>> > Running CPython on it will raise a TypeError, and running Mypy on it
>> > will indicate that no issues were found.
>> >
>> > I
On Mon, Jul 12, 2021 at 12:34 PM Chris Angelico wrote:
> On Tue, Jul 13, 2021 at 5:22 AM lucas wrote:
> > Running CPython on it will raise a TypeError, and running Mypy on it
> > will indicate that no issues were found.
> >
> > I was wondering if there is any way for me to have mypy detecting th
Mmmh, that may work just fine !
Thanks for that idea, ChrisA, i'm looking forward to implement that.
Best wishes,
--lucas
On 12/07/2021 21:33, Chris Angelico wrote:
On Tue, Jul 13, 2021 at 5:22 AM lucas wrote:
Hello everyone,
Let us consider this patch of code:
import argparse
On Tue, Jul 13, 2021 at 5:22 AM lucas wrote:
>
> Hello everyone,
>
> Let us consider this patch of code:
>
> import argparse
>
> def parse_cli() -> argparse.Namespace:
> parser = argparse.ArgumentParser()
> parser.add_argument('n', type=int)
> return parser.par
On 13/01/21 7:13 am, Chris Angelico wrote:
This is what different actions are for. I'd probably use
action="store_true" here; that should mean that args.register will be
set to True if "-r" was passed, or False if it wasn't.
Yes, otherwise it expects another argument following -r
containing a
> I want to have an argument's presence only - value is not required.
> For example, my program main.py needs to know if "-r" is present when program
> is invoked.
> So the value command line would be:
> (1) python3 main.py -r
> or...
> (1) python3 main.py
>
> I tried following:
> parser.add_ar
On Wed, Jan 13, 2021 at 5:01 AM Dhimant Patel wrote:
>
> Its what I searched for on this group.
>
> I want to have an argument's presence only - value is not required.
> For example, my program main.py needs to know if "-r" is present when program
> is invoked.
> So the value command line would b
Thanks for the pointers!
--
https://mail.python.org/mailman/listinfo/python-list
On Tuesday, April 17, 2018 at 7:09:45 PM UTC-5, TUA wrote:
> I'd like to create a script that handles a number of verbs with mandatory and
> /or optional parameters like listed in the table below.
>
> Can ARGPARSE do this and how?
>
> Thanks for all help!
>
>
>
>
>
> Script Verb
will you ever post a single .py file which actually works ?
all the stuff you post is breaking.
--
https://mail.python.org/mailman/listinfo/python-list
On Tuesday, June 27, 2017 at 3:25:10 PM UTC+1, Chris Angelico wrote:
> On Wed, Jun 28, 2017 at 12:09 AM, Fox wrote:
> > what " -h " are you even talkin bout ?
> >
> >
> >
> >
> > def Examples():
> > text = """Lots of examples"""
> > print(text.format())
> >
> >
> >
> > epilog='where the h
On Tuesday, June 27, 2017 at 11:47:42 AM UTC-4, Didymus wrote:
> On Tuesday, June 27, 2017 at 9:56:13 AM UTC-4, Didymus wrote:
> > Greetings,
> >
> > I might be barking up the wrong tree, but was wondering if there's a way to
> > have the argpasre epilog call a function. for example:
> >
> > epi
On Tuesday, June 27, 2017 at 9:56:13 AM UTC-4, Didymus wrote:
> Greetings,
>
> I might be barking up the wrong tree, but was wondering if there's a way to
> have the argpasre epilog call a function. for example:
>
> epilog=Examples()
>
> Where Examples is:
>
> def Examples():
> text = """L
Didymus wrote:
> Greetings,
>
> I might be barking up the wrong tree, but was wondering if there's a way
> to have the argpasre epilog call a function. for example:
>
> epilog=Examples()
>
> Where Examples is:
>
> def Examples():
> text = """Lots of examples"""
> print(text.format())
>
On Wed, Jun 28, 2017 at 12:09 AM, Fox wrote:
> what " -h " are you even talkin bout ?
>
>
>
>
> def Examples():
> text = """Lots of examples"""
> print(text.format())
>
>
>
> epilog='where the heck to put a -h ?? '
>
> epilog=Examples()
List admins, this person has been abusing the p
what " -h " are you even talkin bout ?
def Examples():
text = """Lots of examples"""
print(text.format())
epilog='where the heck to put a -h ?? '
epilog=Examples()
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, Jun 27, 2017 at 11:55 PM, Didymus wrote:
> Greetings,
>
> I might be barking up the wrong tree, but was wondering if there's a way to
> have the argpasre epilog call a function. for example:
>
> epilog=Examples()
>
> Where Examples is:
>
> def Examples():
> text = """Lots of examples"
I did not know about docopt. It is basically the same idea of this recipe I
wrote about 12 years ago:
https://code.activestate.com/recipes/278844-parsing-the-command-line/?in=user-1122360
Good that it was reinvented :-)
--
https://mail.python.org/mailman/listinfo/python-list
> Not sure if this fits the bill, or makes sense here, but I came cross
> "docopt" which touts itself as a "Command-line interface description
> language". I used it in a project and it seems to be pretty easy to use
> as well as elegant. It stores the arguments & values as a dictionary,
> keyed by
On Monday 27 June 2016 06:28 AM, Steven D'Aprano wrote:
> On Monday 27 June 2016 15:34, Lawrence D’Oliveiro wrote:
>
>> On Monday, June 27, 2016 at 4:56:10 PM UTC+12, Sachin Garg wrote:
>>
>>> # Set verbose flag
>>> verbose = False
>>> if arguments['--verbose']:
>>> verbose = True
>>> elif arg
On Monday 27 June 2016 15:34, Lawrence D’Oliveiro wrote:
> On Monday, June 27, 2016 at 4:56:10 PM UTC+12, Sachin Garg wrote:
>
>> # Set verbose flag
>> verbose = False
>> if arguments['--verbose']:
>> verbose = True
>> elif arguments['-q']:
>> verbose = False
>
> Don’t you just love code
On Monday, June 27, 2016 at 4:56:10 PM UTC+12, Sachin Garg wrote:
> # Set verbose flag
> verbose = False
> if arguments['--verbose']:
> verbose = True
> elif arguments['-q']:
> verbose = False
Don’t you just love code (and commenting) like this...
--
https://mail.python.org/mailman/listi
On Sunday 26 June 2016 02:51 PM, Joseph L. Casale wrote:
> I have some code where sys.argv is sliced up and manually fed to discrete
> argparse
> instances each with a single subparser. The reason the discrete parsers all
> having a
> single subparser was to make handling the input simpler, the f
On Monday, June 27, 2016 at 6:56:41 AM UTC+12, Joseph L. Casale wrote:
> This has become unmaintainable as the manual slicing is always subject
> to a new case by where a parser has a positional, switch or optional
> parameter for example. Also, since argv is grouped by subparser
> specifiers, if a
On 12.03.2016 00:18, Fillmore wrote:
Playing with ArgumentParser. I can't find a way to override the -h and
--help options so that it provides my custom help message.
I remember everything being a lot easier using argh instead of argparse.
https://pypi.python.org/pypi/argh#examples
The doc
On Fri, Mar 11, 2016 at 4:18 PM, Fillmore wrote:
>
> Playing with ArgumentParser. I can't find a way to override the -h and
> --help options so that it provides my custom help message.
>
> -h, --help show this help message and exit
>
> Here is what I am trying:
>
> parser = argparse.Argu
On 3/11/2016 6:26 PM, Larry Martell wrote:
am I missing something obvious?
https://docs.python.org/2/library/argparse.html#usage
you rock!
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, Mar 11, 2016 at 6:18 PM, Fillmore wrote:
>
>
> Playing with ArgumentParser. I can't find a way to override the -h and --help
> options so that it provides my custom help message.
>
> -h, --help show this help message and exit
>
> Here is what I am trying:
>
> parser = argparse.A
On Mar 11, 2016 6:20 PM, "Fillmore" wrote:
>
>
> Playing with ArgumentParser. I can't find a way to override the -h and
--help options so that it provides my custom help message.
>
> -h, --help show this help message and exit
>
> Here is what I am trying:
>
> parser = argparse.ArgumentPa
c.bu...@posteo.jp wrote:
> I want to call (on bash) a Python script in this two ways without any
> error.
>
> ./arg.py
> ./arg.py TEST
>
> It means that the parameter (here with the value `TEST`) should be
> optional. With argparse I only know a way to create optional paramters
> when th
Peter Otten <__pete...@web.de> writes:
> I'm not sure about this one; one purpose of REMAINDER is to pass on the
> unprocessed arguments to another program/script, and this might follow the
> same convention. Should
>
> parser.add_argument('-v', '--verbose', action='store_true')
> parser.add_arg
Amit Ramon wrote:
> Peter Otten <__pete...@web.de> [2015-11-06 11:57 +0100]:
>
>
>>>
>>> For example, with the above code
>>>
>>> my_prog -v hello world
>>>
>>> works well, but
>>>
>>> my_prog -v -x hello world
>>>
>>> Fails with an error message 'error: unrecognized arguments: -x'.
>>
>
Peter Otten <__pete...@web.de> [2015-11-06 11:57 +0100]:
For example, with the above code
my_prog -v hello world
works well, but
my_prog -v -x hello world
Fails with an error message 'error: unrecognized arguments: -x'.
This looks like a bug to me. Please report it on bug.python.
Amit Ramon wrote:
> Hello,
>
> I'm trying to use argparse in a program that gets some options and
> positional arguments. I want to collect all the positional arguments
> in a single argument using the REMAINDER option to add_argument() as
> shown bellow:
>
> parser = argparse.ArgumentParser
On 02/22/2014 03:58 AM, Peter Otten wrote:
Larry Hudson wrote:
I have been reading the argparse section of the 3.3 docs, and running all
the example code.
But in section 16.4.2.6. for the formatter_class, the second example in
that section illustrating RawDescriptionHelpFormatter, the example
Larry Hudson wrote:
> I have been reading the argparse section of the 3.3 docs, and running all
> the example code.
>
> But in section 16.4.2.6. for the formatter_class, the second example in
> that section illustrating RawDescriptionHelpFormatter, the example code
> is:
>
> parser = argparse.Ar
On Thu, Jan 9, 2014 at 5:20 AM, Florian Lindner wrote:
> def norm_path(*parts):
> """ Returns the normalized, absolute, expanded and joined path, assembled
> of all parts. """
> parts = [ str(p) for p in parts ]
> return os.path.abspath(os.path.expanduser(os.path.join(*parts)))
Apolo
On 1/8/2014 1:20 PM, Florian Lindner wrote:
I use argparse from Python 3.3.3 with a custom action that normalizes
path arguments:
This works fine when there is actually a --config=path supplied. But
it's not being applied on default arguments.
This behavior is how I interpret the doc.
http:
Florian Lindner wrote:
> I use argparse from Python 3.3.3 with a custom action that normalizes path
arguments:
>
> http://docs.python.org/3/library/argparse.html#action
>
> def norm_path(*parts):
> """ Returns the normalized, absolute, expanded and joined path,
assembled of all parts. """
On 2013-11-22 18:15, Neal Becker wrote:
Robert Kern wrote:
On 2013-11-22 16:52, Neal Becker wrote:
Robert Kern wrote:
On 2013-11-22 14:56, Neal Becker wrote:
I use arparse all the time and find it serves my needs well. One thing I'd
like
to see. In the help message, I'd like to automatica
Robert Kern wrote:
> On 2013-11-22 16:52, Neal Becker wrote:
>> Robert Kern wrote:
>>
>>> On 2013-11-22 14:56, Neal Becker wrote:
I use arparse all the time and find it serves my needs well. One thing I'd
like
to see. In the help message, I'd like to automatically add the default
On 2013-11-22 16:52, Neal Becker wrote:
Robert Kern wrote:
On 2013-11-22 14:56, Neal Becker wrote:
I use arparse all the time and find it serves my needs well. One thing I'd
like
to see. In the help message, I'd like to automatically add the default
values.
What I'd like to see is:
--siz
Robert Kern wrote:
> On 2013-11-22 14:56, Neal Becker wrote:
>> I use arparse all the time and find it serves my needs well. One thing I'd
>> like
>> to see. In the help message, I'd like to automatically add the default
>> values.
>>
>> For example, here's one of my programs:
>>
>> python3 te
On 2013-11-22 14:56, Neal Becker wrote:
I use arparse all the time and find it serves my needs well. One thing I'd like
to see. In the help message, I'd like to automatically add the default values.
For example, here's one of my programs:
python3 test_freq3.py --help
usage: test_freq3.py [-
Eduardo Alvarez wrote:
> When using argparse, is there a way to specify in what order arguments
> get parsed? I am writing a script whose parameters can be modified in
> the following order:
>
> Defaults -> config file -> command-line switches.
>
> However, I want to give the option of specifyin
On 31Aug2013 14:17, Terry Reedy wrote:
| On 8/31/2013 2:13 PM, Terry Reedy wrote:
| >On 8/31/2013 1:11 PM, Eduardo Alvarez wrote:
| >>When using argparse, is there a way to specify in what order arguments
| >>get parsed?
| >
| >I expect argparse to forward iterate the sequence of arguments that it
On 8/31/2013 2:13 PM, Terry Reedy wrote:
On 8/31/2013 1:11 PM, Eduardo Alvarez wrote:
When using argparse, is there a way to specify in what order arguments
get parsed?
I expect argparse to forward iterate the sequence of arguments that it
receives.
Aside from the environment variable soluti
On 8/31/2013 1:11 PM, Eduardo Alvarez wrote:
When using argparse, is there a way to specify in what order arguments
get parsed?
I expect argparse to forward iterate the sequence of arguments that it
receives.
I am writing a script whose parameters can be modified in
the following order:
De
On 2013-08-31 13:11, Eduardo Alvarez wrote:
> When using argparse, is there a way to specify in what order
> arguments get parsed? I am writing a script whose parameters can be
> modified in the following order:
>
> Defaults -> config file -> command-line switches.
>
> However, I want to give the
Le 07/08/2013 01:18, Francois Lafont a écrit :
> For the inheritance of common options, I'll used something like
> that (even if I prefer the oriented object side of the argparse
> module):
But I admit that this is a very simple and intelligent module. ;-)
--
François Lafont
--
http://mail.pyt
Hi,
On relfection, it's clear that:
1. the "(-a -b VALUE-B | -c -d VALUE-D)" syntax is not
implemented by the argparse module;
2. and get this syntax with "argparse + hacking" is not very clean.
So, finally I'll use the docopt module version 0.6.1.
For the inheritance of common options, I'll us
Le 05/08/2013 22:01, Rafael Durán Castañeda a écrit :
> I think you are looking for exclusive groups:
>
> http://docs.python.org/2.7/library/argparse.html#argparse.add_mutually_exclusive_group
Yes... but no. The doc explains you can do this:
my-script (-b VALUE-B | -d VALUE-D)
ie mutally excl
> I think you are looking for exclusive groups:
>
> http://docs.python.org/2.7/library/argparse.html#argparse.add_mutually_excl
> usive_group
No. That links first doc line in that method shows the very point we are all
discussing:
"Create a mutually exclusive group. argparse will make sure that
Le 05/08/2013 16:11, Miki Tebeka a écrit :
> You can probably do something similar using sub commands
> (http://docs.python.org/2/library/argparse.html#sub-commands).
Yes, but this is not the same syntax. I want this syntax :
my-script (-a -b VALUE-B | -c -d VALUE-D)
I don't want this syntax:
El 04/08/13 04:10, Francois Lafont escribió:
Hi,
Is it possible with argparse to have this syntax for a script?
my-script (-a -b VALUE-B | -c -d VALUE-D)
I would like to do this with the argparse module.
Thanks in advance.
I think you are looking for exclusive groups:
http://docs.python.o
> You can probably do something similar using sub commands
> (http://docs.python.org/2/library/argparse.html#sub-commands).
The problem here is that argparse does not pass the subparser into the
parsed args and shared args between subparsers need to be declared
each time. Come execution time, when
> Is it possible with argparse to have this syntax for a script?
> my-script (-a -b VALUE-B | -c -d VALUE-D)
>
> I would like to do this with the argparse module.
You can probably do something similar using sub commands
(http://docs.python.org/2/library/argparse.html#sub-commands).
--
http://mai
On 5 August 2013 03:05, Francois Lafont wrote:
> Hello,
>
> Up. ;-)
>
> Le 04/08/2013 04:10, Francois Lafont a écrit :
>
> > Is it possible with argparse to have this syntax for a script?
> >
> > my-script (-a -b VALUE-B | -c -d VALUE-D)
> >
> > I would like to do this with the argparse module.
>
Hello,
Up. ;-)
Le 04/08/2013 04:10, Francois Lafont a écrit :
> Is it possible with argparse to have this syntax for a script?
>
> my-script (-a -b VALUE-B | -c -d VALUE-D)
>
> I would like to do this with the argparse module.
>
> Thanks in advance.
I have found this post:
https://groups.goo
On Fri, Nov 23, 2012 at 11:46 AM, Roy Smith wrote:
> My command either takes two positional arguments (in which case, both
> are required):
>
> $ command foo bar
>
> or the name of a config file (in which case, the positional arguments
> are forbidden):
>
> $ command --config file
>
> How can I re
On 23 November 2012 18:46, Roy Smith wrote:
> My command either takes two positional arguments (in which case, both
> are required):
>
> $ command foo bar
>
> or the name of a config file (in which case, the positional arguments
> are forbidden):
>
> $ command --config file
>
> How can I represen
On 11/23/2012 1:46 PM, Roy Smith wrote:
My command either takes two positional arguments (in which case, both
are required):
$ command foo bar
or the name of a config file (in which case, the positional arguments
are forbidden):
$ command --config file
How can I represent this with argparse;
Kwpolska wrote:
> I am using argparse in my project. I want to localize it, but it
> seems to be impossible to change some things. See this, for example:
>
> usage: trash [-h] [-V] [-e] [-l] [-r] [-v] [-w] [PLIK [PLIK ...]]
>
> Trashman — menedżer śmietnika XDG w Pythonie.
>
> positional argu
> The standard way, however, is to have a parser that takes the first
> non-option argument as a subcommand name and parses the remaining arguments
> according to that subcommand. Your command line users are more likely to be
> able to understand how to use the program if it works that way.
I'l
On 31 July 2012 13:51, Benoist Laurent wrote:
>
> Le Jul 31, 2012 à 1:45 PM, Oscar Benjamin a écrit :
>
>
>
> On 31 July 2012 12:03, Benoist Laurent wrote:
>
>> Finally.
>>
>> The code I proposed doesn't work in this case: if you add any positional
>> argument to one of the subparsers, then the
1 - 100 of 158 matches
Mail list logo