python_wiki:python_template

Python Template

General Information

Start your script/program using this Python skeleton template.


Usage

Instructions here.

./python-template.py -h

The Code

python-template.py
#!/usr/bin/python
## 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="Put a good program description here.")
parser.add_argument("-n","--name", help="This is your name.", required=True)
parser.add_argument("-e","--email", help="Email results.", action="store_true", required=False)
parser.add_argument("-t","--test", help="Do not make changes; perform a test and output details of what would happen.", action="store_true", required=False)
args = vars(parser.parse_args())
 
# If testing, we don't actually want to do anything
if args['test'] == True:
  print("-->> Test run...no modifications will be made <<--")
 
#===============================
# 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__":
  main()

  • python_wiki/python_template.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)