Learn python the hardway ex17, outside the box -
belive me, i've try best print "to_file" after rewriting in vain ! appears "typeerror: coercing unicode: need string or buffer, file found"
from sys import argv os.path import exists script, from_file, to_file = argv print "copying %s %s" % (from_file, to_file) # these 2 on 1 line, how? in_file = open(from_file) indata = in_file.read() print "the input file %d bytes long" % len(indata) print "does output file exist? %r" % exists(to_file) print "ready, hit return continue, ctrl-c abort." raw_input() out_file = open(to_file, 'w') out_file.write(indata) print "alright, done." out_file.close() in_file.close() print open(out_file).read()
Comments
Post a Comment