Opening websites using Python


Perhaps you need to open a set of websites for doing some work? Maybe opening facebook, twitter and other social networking websites? But you don’t want to click on many bookmarks or type the website’s name in your browser. Then this solution is for you. You can write different scripts for opening different set of websites. You can decide their sequence and even adjust the time between them.

Just change the names of websites in URLS, place them inside quotes ‘xyz_website’ and separate all the websites’ name by commas. Put any number in DELAY variable for the delay in seconds you want between opening of the webpages and you are good to go.

#! python3
import webbrowser
import time

URLS = [
    'http://codereview.stackexchange.com/',
    'http://programmers.stackexchange.com/',
    'http://stackoverflow.com/'
    ]
DELAY = 2

def main():
    for URL in URLS:
        webbrowser.open(URL, 2)
        time.sleep(DELAY)main()

Excuse for cleaning up my code base


I finally got an excuse for cleaning up my code base – Upgrading from Python 2 to python 3. After exactly 2 months with Python 2 I decided to upgrade to Python 3 after a discussion on comp.lang.python. I am glad I am doing that.

I used this excuse to finally merge me C and Python repo that I wanted to do but just wasn’t doing because I didn’t want to do a huge merge without a reason. Now most of my Python code will go through a round of cleaning. All the code that I wrote a complete newbie would be cleaned. I am really glad. That will help me organize my codebase in the long run. I will finally be able to go with the proper timing analysis of my functions and break the big chunk of functions into smaller efficient modules.Learning a lot from all this.

Enjoying it a lot. Python is really great.