> >>> def findself(): > > """Find myself. Ooh look, there I am!""" > import sys > try: > 1/0 > except: > traceback=sys.exc_info()[2] > # Now I'm not sure what to do with traceback. > # traceback.tb_frame.f_code.co_name is the function name ("findself"). > # Is there a way to get the function object?
I'm pretty sure there isn't. I've tried a number of times before to find it but failed. Fundamentally frame objects don't need to know about functions. Functions are just one way of wrapping code objects but sometimes code objects come in modules. You can use sys._getframe() to get the current frame instead of the traceback. Richard -- http://mail.python.org/mailman/listinfo/python-list