from sys import argv import os def copy_file(donor, recipient): with open(donor, "r") as fp_in: with open(recipient, "w") as fp_out: fp_out.write(fp_in.read()) ## murphology: donor might not exist ## undesired clobberage of the recipient if len(argv) < 3: print("Usage: python copy.py donor recipient") quit() donor = argv[1] recipient = argv[2] if not os.path.exists(donor): print(f"File {donor} does not exist.") print("Bailing.....") quit() if os.path.exists(recipient): yn = input(f"Do you want to clobber {recipient}? y/n ") if yn[0] == "n" or yn[0] == "N": print(f"File {recipient} not clobbered") print("quitting") quit() copy_file(donor, recipient)