Created
February 11, 2013 18:21
-
-
Save ashwch/4756378 to your computer and use it in GitHub Desktop.
File Copier ( Distributed Systems Lab)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Program to copy the content of one file to another. | |
| """ | |
| def file_try(): | |
| filename =raw_input("Enter the name of the file: ") | |
| try: | |
| open(filename) | |
| return filename | |
| except: | |
| print "File {0} not found or maybe you don't have enough permissions, Try Again!".format(filename) | |
| return file_try() | |
| if __name__ =='__main__': | |
| file_read=file_try() | |
| if file_read: | |
| file_new=raw_input("Enter the name of the new file: ") | |
| with open(file_read) as f1,open(file_new,'w') as f2: | |
| for line in f1: | |
| f2.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment