what exceptions may file() and read() throw?
Daniel Schüle
uval at rz.uni-karlsruhe.de
Fri Jun 23 10:06:46 EDT 2006
Hello,
currently I am using this instance method
def getFilecontent(self, filename):
try:
return file(filename).read()
except IOError, err_msg:
print err_msg
sys.exit(1)
except:
print "unknown exception in PackageParser"
sys.exit(1)
I tried to open a file for which I don't have the permissions to read
(etc/shadow)
and I tried to open a file which doesn't exist
in both cases I got IOError exception, so my question is
does it make sence to have
except:
print "unknown exception in PackageParser"
sys.exit(1)
or is it a dead code?
are there some good reference sources to see what file() and read()
may throw, IMHO it's OS dependent.
Regards, Daniel
More information about the Python-list
mailing list