Created
December 17, 2019 10:00
-
-
Save martync/ab294fcf2c8585d82415c4103ee9e044 to your computer and use it in GitHub Desktop.
Parse arguments from CLI
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 | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
"action", | |
help="Choose an action to execute", | |
nargs="?", | |
choices=[ | |
"compute_school", | |
"show_school_chart" | |
], | |
) | |
args = parser.parse_args() | |
if args.action == "compute_school": | |
# compute and store result in sql | |
if args.action == "show_school_chart": | |
# show result in a chart | |
# etc... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment