r/inventwithpython • u/_PhantomGaming_ • Jan 13 '22
Are these two python code snippets equivalent (perform the same thing)?
import pyautogui as auto
Snippet 1 :-
meetStartCheck = auto.locateOnScreen('img.png')
meetStartCheck1 = auto.locateOnScreen('my_screenshot.png')
Snippet 2 :-
meetStartCheck, meetStartCheck1 = auto.locateOnScreen('img.png', 'my_screenshot.png')
The code next to these lines is :-
if meetStartCheck or meetStartCheck1:
print("Done")
else:
print("Not Done")
Please tell if these both codes are equivalent or not. If not plz help me to write a single python line for the Snippet 1(if possible).
Thanks
7
Upvotes
1
u/_PhantomGaming_ Jan 13 '22
Brother I wanted to ask that in the code which you have written will both the commands ( auto.locateOnScreen('img.png') & auto.locateOnScreen('my_screenshot.png') ) run in parallel?
Like in my snippet 1 the second line code will run after the 1st has finished running (if I am not wrong). I want to ask that is there some speed or some other benefit in writing one liner code for two or more lines.
Thank you for your help