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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -