Created
July 10, 2011 13:29
-
-
Save oyakata/1074533 to your computer and use it in GitHub Desktop.
argparse?
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
# -*- coding:utf-8 -*- | |
from argparse import ArgumentParser | |
psr = ArgumentParser() | |
add = psr.add_argument | |
add("--conf", default="foo") | |
add("--app", default="bar") | |
args = psr.parse_args("--conf=boo --app=zoo".split()) | |
print args.conf, args.app | |
#=> boo zoo | |
args = psr.parse_args("") | |
print args.conf, args.app | |
#=> foo bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment