Skip to content

Instantly share code, notes, and snippets.

@styrmis
Created December 16, 2011 01:26
Show Gist options
  • Save styrmis/1483971 to your computer and use it in GitHub Desktop.
Save styrmis/1483971 to your computer and use it in GitHub Desktop.
Add a simple flag to a python script, e.g. a --debug flag
from optparse import OptionParser
parser = OptionParser()
parser.add_option("--debug", action="store_true", dest="debug")
(options, args) = parser.parse_args()
# Access the option like so; in this case it will be stored as a boolean
print options.debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment