>>> from decimal import Decimal, getcontext
>>> getcontext().prec = 6
>>> print Decimal('1.234565')
1.234565
>>> getcontext().prec = 2
>>> print Decimal('1.234565')
1.234565
>>> getcontext().prec = 6
>>> print Decimal('1.234565').quantize(Decimal('0.01'))
1.23
This page may have a more recent version on pmwiki.org: PmWiki:UnePageAuHasard, and a talk page: PmWiki:UnePageAuHasard-Talk.