Created
August 28, 2025 03:25
-
-
Save lesserfish/fb18003e257097948d1ba2ae7d9930fd to your computer and use it in GitHub Desktop.
Argparse demo
This file contains hidden or 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 | |
| # Create the parser | |
| parser = argparse.ArgumentParser(description='A simple demo of argparse') | |
| # Add arguments | |
| parser.add_argument('-i', '--input', help='You should know what this does, jackass!') | |
| parser.add_argument('-m', '--mask', help='The mask of the file') | |
| parser.add_argument('-o', '--output', help='The output file, my brother', default = "DEFAULT") | |
| parser.add_argument('--method', help='The output file, my brother', required = True) | |
| # Parse the arguments | |
| args = parser.parse_args() | |
| # Use the arguments | |
| print("The input file is {}".format(args.input)) | |
| print("The output file is {}".format(args.output)) | |
| print("The mask file is {}".format(args.mask)) | |
| print("The method file is {}".format(args.method)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment