print() ignores context ?

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 5 21:07:10 EDT 2020


On 1/05/20 8:33 pm, R.Wieser wrote:
> 
> getcontext().rounding=ROUND_HALF_UP
> 
> print(round(1.5))
> print(round(2.5))

If you're talking about getcontext() from the decimal module,
that only affects operations with Decimals, not regular floats.
Python doesn't provide a way to change the rounding mode for
floats.

-- 
Greg


More information about the Python-list mailing list