Last active
September 18, 2023 08:28
-
-
Save saratrajput/0c6ea9004960de08feeda58d615c42f6 to your computer and use it in GitHub Desktop.
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
""" | |
Module Docstring. | |
author:name | |
date:date | |
""" | |
import argparse | |
import logging | |
# Initialize logging | |
# Add filename='example.log' for logging to file | |
logging.basicConfig(level=logging.INFO) | |
log = logging.getLogger(__name__) | |
def argument_parser(): | |
""" | |
Parse arguments. | |
""" | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--opt_str", type=str, | |
default="string_arg", | |
help="Optional string argument") | |
parser.add_argument("--opt_bool", type=bool, | |
default=True, | |
help="Optional bool argument") | |
parser.add_argument("--opt_int", type=int, | |
default=0, | |
help="Optional int argument") | |
return parser.parse_args() | |
def main(args): | |
""" | |
Implement the main function. | |
""" | |
log.info("Optional arguments: {}, {}, {}".format(args.opt_str, args.opt_bool, | |
args.opt_int)) | |
log.info("Hello, name!") | |
if __name__ == "__main__": | |
args = argument_parser() | |
main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment