Created
November 9, 2020 21:45
-
-
Save tldrafael/7362b02796e93efe1733312b61c43445 to your computer and use it in GitHub Desktop.
Simple snippet to use argparse
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
def parse_args(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-d', type=str, help='directory path', dest='dpath') | |
parser.add_argument('-f', type=str, help='filepath', dest='fpath') | |
return parser.parse_args() | |
if __name__ == '__main__': | |
args = parse_args() | |
if not any([args.dpath, args.fpath]): | |
sys.exit('\tNo arguments provided, check --help') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment