I got to a fun part of the book today where I followed Al Sweigart’s instructions to create a program that would have the computer automatically open the browser with all the top search results on any search topics in new tabs.
So here’s the script – lucky.py:
It was pretty straightforward but when I ran it on Terminal, I encountered errors when I did not give the .py file permission to execute and did not know how to go about searching for the topics on the command line. I Googled for ages but couldn’t seem to find any screenshots that would show me the correct way to do it. All I could find were texts and more texts. Useful but really not useful.
Well, it could be for people with some level of experience with programming but not for me.
(So I asked my boyfriend.)
This is a screenshot of how I changed the lucky.py file’s permissions to make it executable:
I made sure my file was in the current working directory (learning from past mistakes) then ran chmod +x lucky.py.
Once lucky.py was executable, I typed in python3 lucky.py coldplay:
And TA-DA! My browser pops up the following: