Error While Parsing Json using Python – TypeError: list indices must be integers, not str

Jotting this down for fellow googlers. I recently started learning a bit of python and wrote a small script to fetch the latest tweet. When you are new to a programming language, it takes time to grasp some errors. If you see this error while parsing json using python and simplejson, the problem possibly is that, the json is actually encosed in a list [ ]. If you look carefully, you’ll see your json data (pyton dictionary datatype) is actually enclosed in a python list datatype. The following code will reproduce the error. Continue reading

Retreive your Latest Twitter Update (Tweet) using Python

I used to display my latest tweet using PHP code as part of my WordPress theme’s function.php. However that did not work reliably and used to slow down page loading a wee bit. Hence I decided to generate the html code for the latest tweet as a background/cron process and just read the generated data in WordPress. Here’s how I do it. Continue reading