Skip to content

Instantly share code, notes, and snippets.

@nhoffman
Last active May 8, 2024 14:26
Show Gist options
  • Star 68 You must be signed in to star a gist
  • Fork 41 You must be signed in to fork a gist
  • Save nhoffman/3006600 to your computer and use it in GitHub Desktop.
Save nhoffman/3006600 to your computer and use it in GitHub Desktop.
Python script template
#!/usr/bin/env python3
"""A simple python script template.
"""
import os
import sys
import argparse
def main(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'))
args = parser.parse_args(arguments)
print(args)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
@jfbenson
Copy link

jfbenson commented Jul 3, 2023

Thanks for this template!
nit: Sort packages alphabetically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment