> [Guido] > > It looks like if you pass in a context, the Decimal constructor > > still ignores that context: > > > > >>> import decimal as d > > >>> d.getcontext().prec = 4 > > >>> d.Decimal("1.2345678901234567890123456789012345678901234567890000", > > d.getcontext()) > > Decimal("1.2345678901234567890123456789012345678901234567890000") > > >>> > > > > I think this is contrary to what some here have claimed (that you > > could pass an explicit context to cause it to round according to the > > context's precision).
[Tim] > I think Michael Chermside said that's how a particular Java > implementation works. > > Python's Decimal constructor accepts a context argument, but the only > use made of it is to possibly signal a ConversionSyntax condition. You know that, but Raymond seems confused. From one of his posts (point (k)): "Throughout the implementation, the code calls the Decimal constructor to create intermediate values. Every one of those calls would need to be changed to specify a context." But passing a context doesn't help for obtaining the desired precision. PS I also asked Cowlishaw and he said he would ponder it over the weekend. Maybe Raymond can mail him too. ;-) -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com