Last active
December 31, 2021 08:43
-
-
Save pkutaj/6c38f729491f175e6e4962b96ad1b578 to your computer and use it in GitHub Desktop.
template for using Python's argparse module
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
#file: foobar.py | |
import argparse | |
def function_proper(param1, param2) -> None: | |
#CODE... | |
def init_argparse() -> argparse.ArgumentParser: | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--param1") | |
parser.add_argument("--param2") | |
return parser | |
def main() -> None: | |
parser = init_argparse() | |
args = parser.parse_args() | |
function_proper(param1=args.param1, param2=args.param2) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment