Skip to content

Instantly share code, notes, and snippets.

@martync
Created December 17, 2019 10:00
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 martync/ab294fcf2c8585d82415c4103ee9e044 to your computer and use it in GitHub Desktop.
Save martync/ab294fcf2c8585d82415c4103ee9e044 to your computer and use it in GitHub Desktop.
Parse arguments from CLI
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