Last active
June 23, 2025 04:16
-
-
Save nhoffman/3006600 to your computer and use it in GitHub Desktop.
Python script template
This file contains hidden or 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
#!/usr/bin/env -S uv run --script --quiet | |
# /// script | |
# requires-python = ">=3.13" | |
# dependencies = [] | |
# /// | |
"""A simple python script template. | |
""" | |
import argparse | |
import sys | |
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:])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this template!
nit: Sort packages alphabetically.