Created
November 9, 2015 14:39
-
-
Save MagneticMule/27dfd659710684d3ce2c 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
def read_file(file_name): | |
"""reads a file in to memory, | |
first checking the user has access rights to the file""" | |
try: | |
fp = open(file_name, 'r') | |
except IOError as e: | |
if e.errno == errno.EACCES: | |
return False | |
raise | |
else: | |
with fp: | |
return fp.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment