Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print name of def
#1
Hello. I would like to know if there is a way to derive the name of the function that has an exception.
I would like to better highlight through debugging which function is in exception. but writing the name of the function by hand is long and boring.

    def GUI_GetRGB(self, event):
        global CamOpen
        try:
            click_x = int(mouse_over.Mouse_X / (Frame_Width/Pixmap_width))
            click_y = int(mouse_over.Mouse_Y / (Frame_Width/Pixmap_width))
            if not (len(CamFram) == 0):
                self.GUI.TW_WORK.setItem(3, 1, QTableWidgetItem('{},{}' .format(click_x, click_y)))
                R, G, B = CamFram[-1][click_y, click_x]
                self.GUI.TW_WORK.setItem(4, 1, QTableWidgetItem('{},{},{}' .format(R, G, B)))

        except Exception as msg:
            logging.error('Error GUI_GetRGB: ' + str(msg))
Reply
#2
The traceback gives you the information you need. To get that programmatically, see the traceback module (there are examples in there too).
Reply
#3
(Feb-16-2020, 08:04 AM)ndc85430 Wrote: The traceback gives you the information you need. To get that programmatically, see the traceback module (there are examples in there too).

thanks! Smile
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020