A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-September/155369.html below:

[Python-Dev] Change in Python 3's "round" behavior

[Python-Dev] Change in Python 3's "round" behaviorChris Angelico rosuav at gmail.com
Sun Sep 30 19:41:22 EDT 2018
On Mon, Oct 1, 2018 at 9:36 AM Steven D'Aprano <steve at pearwood.info> wrote:
> Then we can add a keyword only argument to round:
>
>     round(number, ndigits=0, *, mode=ROUND_HALF_EVEN)
>
> To use it, you can import the rounding mode you want from math:
>
>     from math import ROUND_CEILING
>     round(x, 3, mode=ROUND_CEILING)

I have no problem with this.

> and everyone is happy (he says optimistically).

And I am as dubious as you are about this :)

IMO, the biggest problem with round() is that it's TOO discoverable.
People reach for it when what they really should be using is string
formatting ("I want to display all these values to three decimal
places"), and then sometimes get bitten when something doesn't
actually display the way they think it will. When it's used correctly,
it's usually fine.

ChrisA
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4