Skip to content

Instantly share code, notes, and snippets.

@hirokiky
Created May 3, 2014 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirokiky/647b8c016d2c66631403 to your computer and use it in GitHub Desktop.
Save hirokiky/647b8c016d2c66631403 to your computer and use it in GitHub Desktop.
import argparse
def parse(args):
parser = argparse.ArgumentParser()
parser.add_argument('--send', choices=['zlib', 'bz2', 'none'], dest='send')
parsed = parser.parse_args(args)
if parsed.send:
return parsed.send
else:
return 'zlib'
if __name__ == '__main__':
print(parse(['--send', 'bz2']))
print(parse([]))
@hirokiky
Copy link
Author

hirokiky commented May 3, 2014

i thought this solution is little shame. cooler one must be there huh.

@aodag
Copy link

aodag commented May 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment