This commit is contained in:
perro tuerto 2023-02-13 11:57:10 -08:00
commit 7e0f0f421b
1 changed files with 21 additions and 0 deletions

21
ex04/ex04.py Normal file
View File

@ -0,0 +1,21 @@
# Exercise 1
# 1. Getting help with -help or -h.
# 2. A least three arguments that are flags, meaning they dont 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)