Built-in Exceptions - How to Find Out Possible Errno's

Mark Peters mpeters42 at gmail.com
Wed Jul 5 18:07:10 EDT 2006


A quick test:

>>> try:
	f = open("foo","r")
except IOError, error:
	print errno.errorcode[error.errno]

ENOENT

It looks to me like your if statement should be as simple as:

if error.errno == errno.ENOENT:
    print os.strerror(error.errno)

Mark




More information about the Python-list mailing list