Re: argparse presence of switch

2021-01-12 Thread Greg Ewing
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

Re: argparse presence of switch

2021-01-12 Thread David Lowry-Duda
> 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

Re: argparse presence of switch

2021-01-12 Thread Chris Angelico
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

argparse presence of switch

2021-01-12 Thread Dhimant Patel
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 be: (1) python3 main.py -r or... (1) python3 main.py I tried foll