Last active
February 8, 2019 21:33
-
-
Save pmav99/880d7e4de5d04098417fdecffbee9dea 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
import argparse | |
def my_func(arg1, arg2, arg3=None): | |
print(arg1, type(arg1)) | |
print(arg2, type(arg2)) | |
print(arg3, type(arg3)) | |
if arg3: | |
print("The boolean value of arg3 is <True>") | |
else: | |
print("The boolean value of arg3 is <False>") | |
def parse_arguments(): | |
parser = argparse.ArgumentParser(description="A pure python 'search & replace' script.") | |
parser.add_argument("--integer", default=0, type=int, help="An integer argument") | |
parser.add_argument("--float", default=0.0, type=float, help="A float argument") | |
# Do, notice that we don't have a default value for "mypath" | |
# So what value will it have? | |
parser.add_argument("--mypath", type=str, help="The path to a file") | |
args = parser.parse_args() | |
return args | |
def main(): | |
args = parse_arguments() | |
my_func(arg1=args.integer, arg2=args.float, arg3=args.mypath) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment