Skip to content

Instantly share code, notes, and snippets.

@glwinsor
Last active May 22, 2018 21:48
Show Gist options
  • Save glwinsor/3b930e474a6603a87ffb39e52a2f0c1e to your computer and use it in GitHub Desktop.
Save glwinsor/3b930e474a6603a87ffb39e52a2f0c1e to your computer and use it in GitHub Desktop.
optparse get options
from optparse import OptionParser
# Get options from the command line
parser = OptionParser()
parser.add_option("-f", "--flag", dest="flag", action="store", type="string", help="Description of flag", metavar="FLAG")
(options, args) = parser.parse_args()
if options.flag == None:
parser.error("Missing argument for --flag ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment