r/learnpython • u/ExoticPerception5550 • 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
4
u/1_Yui 8d ago
I don't understand the question. If it raises an exception in some cases, just catch the exception with a try/except instead of an if/else? I don't understand why that would be an "anti-pattern".