Mark Dickinson <dicki...@gmail.com> added the comment:

> 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.

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4707>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to