Python Forum

Full Version: handling open failures
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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?
(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.