[Python] What is wrong with using a bare 'except'?

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I tried making a function to check if an image is displayed on the screen using PyAutoGui and came up with this:

    def check_image_on_screen(image):
    try:
    pyautogui.locateCenterOnScreen(image)
    return True
    except:
    return False


    And it works fine, but PyCharm tells me I shouldn't leave except bare. What is the problem with leaving it like this? Is there a more appropriate way of creating the same function?

    Continue reading...

Compartilhe esta Página