-
-
Save diegogslomp/72d9466e60a2d89b7d996296107aa502 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 python | |
""" | |
A simple python script template. | |
Get me like this: | |
curl -s 'https://dl.dropbox.com/s/n9ssyqb0ndbm32l/script.py?dl=1' > newname.py | |
Or in your [ba|z]sh.login: | |
function pyscript(){ | |
# Write contents of a simple python script template to stdout. | |
curl -s 'https://dl.dropbox.com/s/n9ssyqb0ndbm32l/script.py?dl=1' | |
} | |
And this is really fun: | |
pyscript | python - -h | |
""" | |
import os | |
import sys | |
import argparse | |
def main(arguments): | |
parser = argparse.ArgumentParser(description=__doc__, | |
formatter_class=argparse.RawDescriptionHelpFormatter) | |
parser.add_argument('infile', help = "A required input file", | |
type = argparse.FileType('r')) | |
parser.add_argument('outfile', help = "A required output file", | |
type = argparse.FileType('w')) | |
parser.add_argument('-a', '--abacad', help='An option') | |
parser.add_argument('-b', '--blabacab', help = "Another option") | |
args = parser.parse_args(arguments) | |
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