Differences
This shows you the differences between two versions of the page.
— |
python_wiki:python_template [2019/05/25 23:50] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Python Template ====== | ||
+ | |||
+ | **General Information** | ||
+ | |||
+ | Start your script/ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Usage ====== | ||
+ | |||
+ | Instructions here. | ||
+ | <code bash> | ||
+ | ./ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== The Code ====== | ||
+ | |||
+ | <code python python-template.py> | ||
+ | # | ||
+ | ## Title: | ||
+ | ## Description: | ||
+ | ## Author: | ||
+ | ## Date: | ||
+ | ## Recent Changes: | ||
+ | |||
+ | # | ||
+ | # Import Modules | ||
+ | # | ||
+ | # argparse: Command line arguments | ||
+ | import argparse | ||
+ | |||
+ | # | ||
+ | # CUSTOMIZE HERE | ||
+ | # | ||
+ | # configure any global variables here | ||
+ | |||
+ | # | ||
+ | # Get Script Arguments | ||
+ | # | ||
+ | # Build argument parser information | ||
+ | parser = argparse.ArgumentParser(description=" | ||
+ | parser.add_argument(" | ||
+ | parser.add_argument(" | ||
+ | parser.add_argument(" | ||
+ | args = vars(parser.parse_args()) | ||
+ | |||
+ | # If testing, we don't actually want to do anything | ||
+ | if args[' | ||
+ | print(" | ||
+ | |||
+ | # | ||
+ | # Functions; Main starts after | ||
+ | # | ||
+ | #def my_function(): | ||
+ | |||
+ | # | ||
+ | # Main Program Control | ||
+ | # | ||
+ | def main(): | ||
+ | # Do some stuff | ||
+ | return 0 | ||
+ | ## End of Main ## | ||
+ | |||
+ | # | ||
+ | # Execute Main Program | ||
+ | # | ||
+ | if __name__ == " | ||
+ | main() | ||
+ | </ | ||
+ | |||
+ | ---- | ||