Irit Katriel <[email protected]> added the comment:
The documentation for open says "If the file cannot be opened, an OSError is
raised."
NotADirectoryError and FileNotFoundError are both OSErrors.
So the correct way to write Danny's code snippet, according to the
documentation, is:
try:
open('/path/to/file/somename.txt')
except OSError:
"""do something"""
----------
components: +IO
nosy: +iritkatriel
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41737>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com