Irit Katriel <iritkatr...@yahoo.com> 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 <rep...@bugs.python.org> <https://bugs.python.org/issue41737> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com