How to identify what function call raise an exception in Python?

Posted by boos on Stack Overflow See other posts from Stack Overflow or by boos
Published on 2010-03-04T14:40:42Z Indexed on 2010/03/27 17:43 UTC
Read the original article Hit count: 267

Filed under:
|

i need to identify who raise an exception to handle better str error, is there a way ?

look at my example:

try:
   os.mkdir('/valid_created_dir')
   os.listdir('/invalid_path')
except OSError, msg:

   # here i want i way to identify who raise the exception
   if is_mkdir_who_raise_an_exception:
      do some things

   if is_listdir_who_raise_an_exception:
      do other things ..

how i can handle this, in python ?

© Stack Overflow or respective owner

Related posts about python

Related posts about exception