As @bowlofred explained - the canonic way is to try to open and handle the exception. Checking if file exists and then try to open it is prone to race condition - the file may be deleted/renamed between your check and your attempt to work with it.
As a side note - it's better using
As a side note - it's better using
with
context manager when open the file
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs