
May 21, 2005
12:07 a.m.
Guido writes:
It looks like if you pass in a context, the Decimal constructor still ignores that context
No, you just need to use the right syntax. The correct syntax for converting a string to a Decimal using a context object is to use the create_decimal() method of the context object:
import decimal decimal.getcontext().prec = 4 decimal.getcontext().create_decimal("1.234567890") Decimal("1.235")
Frankly, I have no idea WHAT purpose is served by passing a context to the decimal constructor... I didn't even realize it was allowed! -- Michael Chermside