Created
December 17, 2012 06:01
-
-
Save hongqn/4316106 to your computer and use it in GitHub Desktop.
Template for main.py If you use vim, you can use https://github.com/aperezdc/vim-template or https://github.com/mattn/zencoding-vim to create it whenever you need a main script in python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
import argparse | |
def main(args): | |
pass | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser( | |
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | |
parser.add_argument('-v', '--verbose', action='store_true') | |
parser.add_argument('-q', '--quiet', action='store_true') | |
args = parser.parse_args() | |
if args.verbose: | |
loglevel = logging.DEBUG | |
elif args.quiet: | |
loglevel = logging.WARNING | |
else: | |
loglevel = logging.INFO | |
logging.basicConfig(level=loglevel) | |
sys.exit(main(args)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment