How to get function name which raised IOError/OSError?
Inyeol Lee
inyeol_lee at yahoo.com
Thu Sep 5 05:04:35 EDT 2002
Is there any way to get function name which raised IO/OSError?
I want to write an error message formatter like;
def print_oserror():
e = sys.exc_info()
func = get_func(e) # I don't know how to implement this.
print "cannot %s %s: %s." % (func, e[1].filename, e[1].strerror)
try:
os.mkdir("foo")
os.chdir("bar")
os.rmdir("baz")
except OSError:
print_oserror() # print message like 'cannot chdir bar: blabla...'
Thanks,
Inyeol Lee
More information about the Python-list
mailing list