Message78118
> Why do you say the return type is incorrect? It should, and does,
> return a float.
The documentation at:
http://docs.python.org/dev/3.0/library/functions.html#round
says, of round(x[, n]):
"""The return value is an integer if called with one argument, otherwise
of the same type as x."""
On the other hand, PEP 3141 (which I didn't check before) seems to say
that you're right: the return value should be an instance of Real.
So maybe this is just a doc bug?
I have to admit that I don't understand the motivation for round(int, n)
returning a float, given that the value will always be integral. It seems
that this makes the two-argument version of round less useful to someone
who's trying to avoid floats, perhaps working with ints and Decimals, or
ints and Rationals, or just implementing fixed-point arithmetic with
scaled ints.
But given that a behaviour change would be backwards incompatible, and the
current behaviour is supported by at least one documentation source, it
seems easiest to call this a doc bug. |
|
Date |
User |
Action |
Args |
2008-12-20 19:11:45 | mark.dickinson | set | recipients:
+ mark.dickinson, loewis, giampaolo.rodola, dingo |
2008-12-20 19:11:45 | mark.dickinson | set | messageid: <1229800305.92.0.585797780366.issue4707@psf.upfronthosting.co.za> |
2008-12-20 19:11:45 | mark.dickinson | link | issue4707 messages |
2008-12-20 19:11:44 | mark.dickinson | create | |
|