Creating hidden arguments with Python argparse

Is it possible to add an argument in python argparse.ArgumentParser without its appearing in use or help ( script.py --help )?

+101
python argparse
Jun 20 '12 at 7:15
source share
1 answer

Yes, you can set the help parameter to add_argument on argparse.SUPPRESS . Here is an example from the argparse documentation :

 >>> parser = argparse.ArgumentParser(prog='frobble') >>> parser.add_argument('--foo', help=argparse.SUPPRESS) >>> parser.print_help() usage: frobble [-h] optional arguments: -h, --help show this help message and exit 
+141
Jun 20 '12 at 7:19
source share



All Articles