[Tutor] Equivalent exception of os.path.exists()

Alan Gauld alan.gauld at btinternet.com
Mon Nov 30 22:59:53 CET 2009

"Dave Angel" <davea at ieee.org> wrote

> My suspicion is that the author just wants you to try to do an open() 
> (readonly), inside a try/except block, and to successfully handle the 
> exception.  

And the critical thing here is that it must be an open in read mode. 
As others pointed out if you use write mode it will (nearly) always 
succeed, even if that means overwriting an existing file.

Alan G.

More information about the Tutor mailing list