Skip to content

Instantly share code, notes, and snippets.

@oyakata
Created July 10, 2011 13:29
Show Gist options
  • Save oyakata/1074533 to your computer and use it in GitHub Desktop.
Save oyakata/1074533 to your computer and use it in GitHub Desktop.
argparse?
# -*- 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