I want to make a script in python and then run it from the command line. The script is called test.py and the command to run it is:
python3 test.py John Jackson
Here is the expected output:
John Jackson
And here is the python script I made:
class person:
def __init__(self, first, last):
self.firstname = first
self.lastname = last
def get_first(self):
return self.firstname
def get_last(self):
return self.lastname
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument('first')
parser.add_argument('last')
args = parser.parse_args()
c1 = person(args.first, args.last)
print(c1)
But the problem is when I run the script from the command line using the mentioned command, it returns nothing. Do you know how to fix it and get the expected output?
main. Some other languages may do that, but not Python.