import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--date', help='date of event', type=str)
parser.add_argument('-t', '--time', help='time of event', type=str)
args = parser.parse_args()
print(f'Event was on {args.date} at {args.time}')
#!/usr/bin/python
import sys
for args in sys.argv:
print(args)
"""
If you were to call the program with subsequent arguments, the output
will be of the following
Call:
python3 sys.py homie no
Output:
sys.py
homie
no
"""
import sys
print ("the script has the name %s" % (sys.argv[0])
#in python, arguments can be used using keywords
#the format is:
def function(arg,kwarg='default'):
return [arg,kwarg]
def greet(name, msg):
"""This function greets to
the person with the provided message"""
print("Hello", name + ', ' + msg)
greet("Monica", "Good morning!")