Skip to content

Instantly share code, notes, and snippets.

@kevinkirkup
Created September 8, 2012 11:46
Show Gist options
  • Save kevinkirkup/3674112 to your computer and use it in GitHub Desktop.
Save kevinkirkup/3674112 to your computer and use it in GitHub Desktop.
Pythonx - argparse example
import argparse
##################################################
# Create the argument parser
# http://docs.python.org/dev/library/argparse.html
##################################################
parser = argparse.ArgumentParser(description="Parse arguments")
parser.add_argument("input_file", action="store", help="File to read", metavar="INFILE")
parser.add_argument("output_file", action="store", default="output.txt", help="File to write", metavar="OUTFILE")
args = parser.parse_args()
input_file = args.input_file
output_file = args.output_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment