Mark Dickinson added the comment:
The old behaviour certainly can be emulated, but doing that correctly would
require 4 or 5 lines of code. I don't know enough about 2to3 to know whether
it can handle that sort of translation, but even if it can, I'd guess that in a
good proportion of cases the loss in readability (and possibly also in
performance) wouldn't be worth it, and in many cases the difference in
behaviour may not matter either. Given all that, I think it's probably better
left as a judgement call on the part of the person doing the 2-to-3 porting.
Here's a translation that's immune from the two issues I pointed out.
def round_ties_away_from_zero(x):
n = round(x)
if abs(x - n) == 0.5: # x - n is exact; no rounding error
return x + copysign(0.5, x)
else:
return float(n)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24403>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com