# copy_file.py # # Copy the contents of the source file to the desination file. # from sys import argv def copy_file(from_file_name, to_file_name): """ Copy the contents of the source file named from_file_name to the desination file named to_file_name. Create the destination file if it doesn't already exist. Overwrite the current contents of an existing destination file. """ from_file = open(from_file_name, mode='r') to_file = open(to_file_name, mode='w') contents = from_file.read() to_file.write(contents) if __name__ == '__main__': if len(argv) != 3: print('Usage: ipython copy_file.py source_file_name target_file_name') else: copy_file(argv[1], argv[2])