Should probably use iteritems(). I don't think you can iterate over a dictionary directly.