GIST: GetOpt for Python

Although its origin lies in the C language, I find myself using GetOpt in python scripts often. It’s probably just familiarity. To speed up getting started with a python script I made the following gist that I can drag in and get rolling with script configuration quickly.

Modifications Required

  • Adjust the printHelp() to suit the needs of the desired script.
  • Adjust the shortOptions variable to match the options described in printHelp(). Options characters that are followed with a colon are mandatory arguments.
  • Add or remove if and elif statements to interpret every option listed in printHelp().