↧
Answer by wyk for Check to see if file exists is failing
this script opens a file in "w" mode (write mode),which means once the file dose not exist,it will be created. So No IOError.
View ArticleAnswer by pwuertz for Check to see if file exists is failing
This is a slightly modified version of Lattywares solution. Since it is not possible to append data to the beginning of a file, the whole content is read and the file is written anew including your...
View ArticleAnswer by Gareth Latty for Check to see if file exists is failing
The correct course of action here is to try and read the file, if it works, read the data, then write to the file with the new data.Writing to a file will create the file if it doesn't exist, and...
View ArticleAnswer by octopusgrabbus for Check to see if file exists is failing
I believe you are always creating the file. Therefore, you won't see a file not there exception. It does not hurt to put a write or file open write under try except, because you might not have...
View ArticleCheck to see if file exists is failing
Here is my code:# header.pydef add_header(filename): header = '"""\nName of Project"""' try: f = open(filename, 'w') except IOError: print "Sorry could not open file, please check path" else: with f:...
View Article
More Pages to Explore .....