commit 7e0f0f421bcbf548c38b189589f0907cb2b08d13 Author: perro Date: Mon Feb 13 11:57:10 2023 -0800 Movement diff --git a/ex04/ex04.py b/ex04/ex04.py new file mode 100644 index 0000000..47339f7 --- /dev/null +++ b/ex04/ex04.py @@ -0,0 +1,21 @@ +# Exercise 1 +# 1. Getting help with -help or -h. +# 2. A least three arguments that are flags, meaning they don’t take an extra +# argument but simply putting them on the command line turns something on. +# 3. At least three arguments that are options, meaning they do take an +# argument and set a variable in your script to that option. +# 4. Additional “positional” arguments, which are lists of files at the end of +# all the – style arguments and can handle Terminal wildcards like */.txt. + +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('filename') +parser.add_argument('-o1', '--opt1') +parser.add_argument('-o2', '--opt2') +parser.add_argument('-o3', '--opt3') +parser.add_argument('-f1', '--flag1', action='store_true') +parser.add_argument('-f2', '--flag2', action='store_true') +parser.add_argument('-f3', '--flag3', action='store_true') +args = parser.parse_args() +print(args)