Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Boolean Flags

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--color',   help='The name of the color')
parser.add_argument('--verbose', help='Print more data',
    action='store_true')
args = parser.parse_args()

print(args.color)
print(args.verbose)

python argparse_boolean.py --color Blue --verbose

Blue
True

python argparse_boolean.py

None
False