Created
April 6, 2020 19:59
-
-
Save g1eb/a2c9e7ce0053eba2b7bb467e65df552e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, errno | |
if __name__ == "__main__": | |
try: | |
with open(sys.argv[1]) as f: | |
s = f.read() | |
print('read', len(s), 'bytes.') | |
except IOError as x: | |
if x.errno == errno.ENOENT: | |
print(sys.argv[1], '- does not exist') | |
elif x.errno == errno.EACCES: | |
print(sys.argv[1], '- cannot be read') | |
else: | |
print(sys.argv[1], '- some other error') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment