Category Archives: python

Fun with Context Managers

Sometimes I need a simple stop watch in my Python scripts to find out how expensive my code is in wall clock time. The problem is trivial to solve, but I thought I’d give it a try using Python’s with … Continue reading

Posted in python | Tagged , | Leave a comment

Plotting with Matplotlib

For a long time, Gnuplot has been my tool of choice for plotting diagrams. The diagrams it produces out of the box look very scientific, but it takes a lot of tweaking to produce something that’s visually pleasing. I got … Continue reading

Posted in python | Tagged , , , | 2 Comments

A Template for Python Unix Utilities

One of the most often read postings on this blog is the one about my getopts-enabled shell script template. So I figured, a similar template in Python would also be useful. Like the shell script, it’s quite trivial, but it … Continue reading

Posted in python | Tagged , , | 2 Comments

Quick Tip #3: Creating Histograms in Python

Since Python 2.5, creating histograms has become easier. Instead of dict, we can now use defaultdict which is similar in behavior to awk’s associative arrays. Instead of raising a KeyError for undefined keys, defaultdict adds a user-defined item and returns … Continue reading

Posted in python | Tagged , | 2 Comments

Django on Google App Engine

I’m back to playing with the Django web development framework again. Since I’m close to putting something online (it’s only a matter of years, actually), I’m also looking into hosting options. Due to the framework choice, Google App Engine appeared … Continue reading

Posted in python | Tagged , , , , | Leave a comment

Transcoding Files to Ogg Vorbis

I’ve got a nice MP3 player from Samsung with 2 GB of flash memory. That’s very little and I can never decide which files to keep and which to delete. Fortunately, the player also supports Ogg Vorbis files that require … Continue reading

Posted in python | Tagged , , | 1 Comment

Using ReStructured Text with WordPress

Writing long documents in a browser input box isn’t the most pleasant thing to do. The WordPress builtin editor makes things even more inconvenient by forcing you to write your articles in HTML. It would be pretty cool if you … Continue reading

Posted in python | Tagged , , | 9 Comments

Map/Reduce in Python

My interest in Grid Computing over the last weeks begins to show. After reading the Google MapReduce paper, I tried my fingers on a client side toy problem. For formatting purposes, I was interested in the size of the longest … Continue reading

Posted in python | Tagged , | 4 Comments