Posts for Tag -- python

Argparse Shell

I recently built a toy project for Riak that allows me to tag files with tags and various other metadata. In the course of building it I continually thought that it would be nice to have a shell to issue commands in, perhaps even an extension of zsh that temporarily sets in scope functions, somewhat like virtualenv does. At the same time I came across argparse. It is a nice extension to OptionParser which I used a great deal, with included support for things like subcommands which fit nicely into the shell parsing area. It turns out that it worked perfectly as a simple parser.

Failing Properly

Recently I've run into more and more code from programmers that simply don't know how to handle errors and exceptions. The other day I had to replace something like 30 generic try/excepts to actually figure out what the bug was that I was trying to fix. And unsurprisingly, there were numerous bugs that were hiding beneath the generic try/excepts. Below are some guidelines for failing properly. Though the code is in python, the concepts apply to many languages.

New Django Project

Recently I've been working on a new project in django, Squirt Blurt. It's been taking up a large majority of my time, so I haven't had much time to create new posts or work on other projects, but I just thought I would give a few impressions of things I learned/did along the way.

Lazy Dictionaries

In a language like Python, not many things are lazy evaluated by nature, as opposed to a language like Haskell where everything is lazy by nature. Python does have generators that provide lazy iterations, but it is easy to also create lazy dictionaries and other data structures.