Skip to content

Instantly share code, notes, and snippets.

@HedgehogCode
Forked from nhoffman/pyscript.py
Last active March 12, 2019 14:51
Show Gist options
  • Select an option

  • Save HedgehogCode/10ffa17061736e46adcc958c8e9f8b77 to your computer and use it in GitHub Desktop.

Select an option

Save HedgehogCode/10ffa17061736e46adcc958c8e9f8b77 to your computer and use it in GitHub Desktop.
Python script template
#!/usr/bin/env python
"""A simple python script template.
"""
from __future__ import print_function
import sys
import argparse
def main(args):
print(args)
def parse_args(arguments):
"""Parse the command line arguments."""
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('infile', help="Input file",
type=argparse.FileType('r'))
parser.add_argument('-o', '--outfile', help="Output file",
default=sys.stdout, type=argparse.FileType('w'))
return parser.parse_args(arguments)
if __name__ == '__main__':
sys.exit(main(parse_args(sys.argv[1:])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment