model-view-controller pattern if __name__ ="__main__"main(sys argv[ ]the program uses the sys package in the standard library to expose the arguments passed to the program the first argument is the name of the script being executed in our example programthe first additional argument that is expected is the name of person we have some checks includedensuring that some string was in fact passed to the program nextwe check if the program encountered the name previouslyand it displays the relevant text nowfor all the reasons discussed throughout the bookwe know that this is not good the script is doing too much in the main functionso we proceed to decompose it into different functions import sys import os def get_append_write(filename)if os path exists(filename)return 'areturn 'wdef name_in_file(filenamename)if not os path exists(filename)return false return name in read_names(filenamedef read_names(filename)with open(filename' 'as data_filenames data_file read(split('\ 'return names def write_name(filenamename)with open(filenameget_append_write(filename)as data_filedata_file write("{}\nformat(name)def get_message(name)if name_in_file('names dat'name)return "welcome back {}!format(name