FAQ
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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedSep 5, '02 at 9:04a
activeSep 5, '02 at 9:04a
posts1
users1
websitepython.org

1 user in discussion

Inyeol Lee: 1 post

People

Translate

site design / logo © 2022 Grokbase