def FileCheck(fn): try: fn=open(\"TestFile.txt\",\"U\") except IOError: print \"Error: File does not appear to exist.\"
This is likely because you want to open the file in read mode. Replace the "U" with "r".
Of course, you can use os.path.isfile('filepath') too.
os.path.isfile('filepath')