forked from bugcy013/pyway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex17.py
39 lines (23 loc) · 773 Bytes
/
ex17.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# code file for ex17
# More files
# import 'argv' as a variable
from sys import argv
# import 'exists' as a function
from os.path import exists
# imply how this works in the shell code
script, from_file, to_file = argv
print "Coping from %s to %s." % (from_file, to_file )
# we could do these two lines on one line, how ?
# only need to use a ';' to connect
#in_file = open(from_file);indata = in_file.read()
# new version
indata = open(from_file).read()
print "The input file is %d bytes long. " % len(indata )
print "Does the output file exist %r ?" % exists(to_file )
print "Ready, hit RETURN to cotinue, CTRL-C to abort."
raw_input()
out_file = open(to_file,'w')
out_file.write(indata)
print "Alright, all done."
out_file.close()
#in_file.close()