Created
December 16, 2011 01:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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