Last active
May 30, 2018 16:13
-
-
Save cdjoubert/e264d2307094988c608b7dff603aed7a to your computer and use it in GitHub Desktop.
Basic usage of argparse in python
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
import argparse | |
# See also Python boilerplates: | |
# https://www.python-boilerplate.com/py2+executable+argparse+logging | |
# https://gist.github.com/ssokolow/151572 | |
parser = argparse.ArgumentParser(description="Description") | |
parser.add_argument('--output','-o', help='Output file', default='out.csv') | |
# with type information: | |
parser.add_argument("-b", "--bits", help="bits", type=int, default=16) | |
# Store True: | |
parser.add_argument('--json-stdin', '-i', action='store_true', help='read a JSON') | |
# arguments: | |
parser.add_argument('arguments', nargs='*', help='command name and arguments') | |
args = parser.parse_args() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment