-
Notifications
You must be signed in to change notification settings - Fork 100
Python
Matt Harley edited this page Oct 9, 2015
·
4 revisions
- (from https://www.reddit.com/r/Python/comments/3nctlm/what_python_tools_should_i_be_using_on_every/)
- http://gouge.readthedocs.org/en/latest/
# My recommendation is argparse, it's usually more than powerful enough and comes with python. You can even pass in a list of arguments (default of None means that it uses sys.argv) so that you can automate testing of your command line arguments too.
parser.add_argument('-v', '--verbose', action='count', default=0)
parser.add_argument('-q', '--quiet', action='count', default=0)
logging_level = logging.WARN + 10*args.quiet - 10*args.verbose
# script -vv -> DEBUG
# script -v -> INFO
# script -> WARNING
# script -q -> ERROR
# script -qq -> CRITICAL
# script -qqq -> no logging at all