How to round Python Decimal instance
<p>How do I round a Python Decimal instance to a specific number of digits while rounding to the nearest decimal?</p>

<p>I've tried using the <code>.quantize(Decimal('.01'))</code> method outlined in the <a href="http://docs.python.org/release/3.1.5/library/decimal.html#decimal.Context" rel="nofollow">docs</a>, and suggested in <a href="http://stackoverflow.com/questions/7515266/rounding-problem-with-python">previous answers</a>, but it doesn't seem to round correctly despite trying different ROUND_ options. I've also tried setting getcontext().prec, but that seems to only control the total number of digits in the entire number, not just the decimals.</p>

<p>e.g. I'm trying to do something like:</p>

<pre><code>assert Decimal('3.605').round(2) == Decimal('3.61')
assert Decimal('29342398479823.605').round(2) == Decimal('29342398479823.61')
assert Decimal('3.604').round(2) == Decimal('3.60')
assert Decimal('3.606').round(2) == Decimal('3.61')
</code></pre>
