With the following code:
import argparse
parser = argparse.ArgumentParser(description="Prepare something code.")
parser.add_argument("-t","--tabular", help="print something in tabular way for EXCEL",
action="store_true")
parser.add_argument("-v","--verbose", action="store_true")
args = parser.parse_args()
if args.tabular:
print "Tabular print"
elif args.verbose:
print "VERBOSE"
It's only when I execute it the following way, that it prints usage:
$ python mycode.py -h
usage: mycode.py [-h] [-t] [-v]
Prepare something code.
optional arguments:
-h, --help show this help message and exit
-t, --tabular print something in tabular way for EXCEL
-v, --verbose
What I want to do is to simply run the code: $ my code.py
without any -h
option whatsoever to print the usage. How can I do that?