[issue19933] Round default argument for "ndigits"

2015-04-15 Thread Steve Dower
Changes by Steve Dower : -- resolution: -> fixed status: open -> closed versions: +Python 3.5 -Python 3.4 ___ Python tracker ___ ___

[issue19933] Round default argument for "ndigits"

2015-04-15 Thread Roundup Robot
Roundup Robot added the comment: New changeset e3cc75b1000b by Steve Dower in branch 'default': Issue 19933: Provide default argument for ndigits in round. Patch by Vajrasky Kok. https://hg.python.org/cpython/rev/e3cc75b1000b -- nosy: +python-dev ___

[issue19933] Round default argument for "ndigits"

2013-12-13 Thread Terry J. Reedy
Terry J. Reedy added the comment: The docstring is better than the current doc as it says that the default precision is 0, without calling that the default for ndigits. ''' round(number[, ndigits]) -> number Round a number to a given precision in decimal digits (default 0 digits).

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Vajrasky Kok
Vajrasky Kok added the comment: In case we want to add consistency with None ndigits, here is the patch adding support for None value for ndigits parameter. This one looks like a low-risk addition but since Python 3.4 is in beta phase -- Added file: http://bugs.python.org/file330

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: > Anyway, why not round(1.2) -> 1.0 in the first place? Just curious. All this changed as part of PEP 3141. I wasn't watching Python 3 development closely back then, but I *think* at least part of the motivation was to provide a way to get away from the use o

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread R. David Murray
R. David Murray added the comment: Right, but None in that case has real world utility, since you might have the the value in a variable. But you are hardly going to hold int-or-not in a variable, especially a variable that is really about the number of places in the float result...

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread João Bernardo
João Bernardo added the comment: Not really. Just consistency: For the same reason ' foo '.strip(None) works... To avoid special casing the function call when you already have a variable to hold the argument. -- ___ Python tracker

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread R. David Murray
R. David Murray added the comment: Do you have any real-world motivating use case for None? Not just theoretical consistency with what a Python version of the function would look like. (I'm not saying we shouldn't consider supporting None as a low priority change, I'm just trying to figure o

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread João Bernardo
João Bernardo added the comment: > Anyway, why not round(1.2) -> 1.0 in the first place? Just curious. It was the behavior on Python 2.x, but somehow when they changed the rounding method to nearest even number this happened... I think it's too late to change back the return type. --

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Vajrasky Kok
Vajrasky Kok added the comment: Here is the updated doc fix. Anyway, why not round(1.2) -> 1.0 in the first place? Just curious. -- Added file: http://bugs.python.org/file33060/fix_doc_round_ndigits_v2.patch ___ Python tracker

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread João Bernardo
João Bernardo added the comment: > I don't understand. There's already a way to make round return an integer: > don't pass a second argument. If this function were to be written in Python, it would be something like: def round(number, ndigits=0): ... or def round(number, nd

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: How about just removing the mention of 'defaults to zero', and say something like: "if ndigits is omitted, returns the nearest int to its input" -- ___ Python tracker

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: Thanks. It's inaccurate to say that a float is returned in general, though: for most builtin numeric types, what's returned has the same type as its input. So rounding a Decimal to two places gives a Decimal on output, etc. (That's already explained in the

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Vajrasky Kok
Changes by Vajrasky Kok : Added file: http://bugs.python.org/file33054/fix_doc_round_ndigits.patch ___ Python tracker ___ ___ Python-bugs-list

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Vajrasky Kok
Changes by Vajrasky Kok : Removed file: http://bugs.python.org/file33053/fix_doc_round_ndigits.patch ___ Python tracker ___ ___ Python-bugs-li

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Vajrasky Kok
Changes by Vajrasky Kok : Removed file: http://bugs.python.org/file33052/fix_doc_round_ndigits.patch ___ Python tracker ___ ___ Python-bugs-li

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Vajrasky Kok
Vajrasky Kok added the comment: Okay, here is the patch to fix the doc. -- Added file: http://bugs.python.org/file33052/fix_doc_round_ndigits.patch ___ Python tracker ___ ___

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Vajrasky Kok
Changes by Vajrasky Kok : Added file: http://bugs.python.org/file33053/fix_doc_round_ndigits.patch ___ Python tracker ___ ___ Python-bugs-list

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: > But also there should be a way to make round return an integer I don't understand. There's already a way to make round return an integer: don't pass a second argument. -- ___ Python tracker

[issue19933] Round default argument for "ndigits"

2013-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: > After patch: > round(1.23, 0) => 1 not 1.0 > round(4.67, 0) => 5 not 5.0 Please no! Two-argument round should continue to return a float in all cases. The docs should be fixed. -- ___ Python tracker

[issue19933] Round default argument for "ndigits"

2013-12-08 Thread Vajrasky Kok
Changes by Vajrasky Kok : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue19933] Round default argument for "ndigits"

2013-12-08 Thread Vajrasky Kok
Vajrasky Kok added the comment: Here is the preliminary patch. After patch: round(1.23, 0) => 1 not 1.0 round(4.67, 0) => 5 not 5.0 -- keywords: +patch nosy: +vajrasky Added file: http://bugs.python.org/file33051/fix_round_with_zero_ndigits.patch _

[issue19933] Round default argument for "ndigits"

2013-12-08 Thread João Bernardo
New submission from João Bernardo: >From the docs for built-in function "round": "If ndigits is omitted, it defaults to zero" (http://docs.python.org/3/library/functions.html#round) But, the only way to get an integer from `round` is by not having the second argument (ndigits): >>> r