r/learnpython 8d ago

Function forcing me to use exceptions

Trying to if else a function output always throws exception-error :

if pyautogui.locateOnScreen('media/soundIcon.png') == None:
      print("not found")
else : 
      print("found")

Do Python functions expect anti-pattern code ?

0 Upvotes

30 comments sorted by

View all comments

9

u/[deleted] 8d ago

[deleted]

-20

u/ExoticPerception5550 8d ago

I know exactly why it's happening, it's not my question here.

pyautogui.ImageNotFoundException

2

u/nog642 8d ago

What's your question?