Python Forum
handling open failures - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: handling open failures (/thread-23594.html)



handling open failures - Skaperen - Jan-07-2020

do all open() failures always cause an exception in the open() call and never just return a None or something else that could cause an exception later on? i'm wanting to move some failure handling to with open() that could be awkward if it needs to also check for returned errors.


RE: handling open failures - Gribouillis - Jan-07-2020

The doc says
Output:
Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised.
Why not believe it?


RE: handling open failures - Skaperen - Jan-08-2020

(Jan-07-2020, 09:59 PM)Gribouillis Wrote: The doc says
Output:
Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised.
Why not believe it?

because i didn't see that line.