Why Python 2.7 only? This looks like it would be Python 3 code if you simply changed<p><pre><code> print str(err)
</code></pre>
to:<p><pre><code> print(str(err))
</code></pre>
Except, that's a pretty unhelpful thing to print. I believe a much better statement to put there, in Python 2 or 3, would be:<p><pre><code> raise</code></pre>