Hi, I’ve bought the book for learning Python and I’m starting to have issues in some exercises when I try to run the scrips in Pythonista.
I’m convinced that the problem could be on file structure or the way I put the arguments because in a regular computer the scripts run ok.
I paste the script hoping for anyone that can give me a hand.
Thanks.
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print(f"Copying from {from_file} to {to_file}")
# we could do these two on one line, how?
in_file = open(from_file)
indata = in_file.read()
print(f"the input file is {len(indata)} bytes long")
print(f"Does the output file exist? {exists(to_file)}")
print("Ready, hit RETURN to continue, CTRL-C to abort.")
input()
out_file = open(to_file, 'w')
out_file.write(indata)
print("Alright, all done.")
out_file.close()
in_file.close()