(Jul-14-2017, 08:22 PM)DeaD_EyE Wrote: Instead of checking every possible possibility, you should use try: except:I agree with this.
There is a couple of thing that can be done different.
No need to import sys and use file=sys.stderr,just print error give the same.
and use
with open()
.>>> try: ... with open('ll.txt') as f: ... f.read() ... except OSError as error: ... print(error) [Errno 2] No such file or directory: 'll.txt' >>> import sys >>> try: ... with open('ll.txt') as f: ... f.read() ... except OSError as e: ... print(e, file=sys.stderr) [Errno 2] No such file or directory: 'll.txt'