[New-bugs-announce] [issue19933] Round default argument for "ndigits"

João Bernardo report at bugs.python.org
Mon Dec 9 05:24:20 CET 2013


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):

    >>> round(3.5)
    4
    >>> round(3.5, 1)
    3.5
    >>> round(3.5, 0)
    4.0
    >>> round(3.5, -1)
    0.0
    >>> round(3.5, None)
    Traceback (most recent call last):
      File "<pyshell#6>", line 1, in <module>
        round(3.5, None)
    TypeError: 'NoneType' object cannot be interpreted as an integer


Either the docs are wrong or the behavior is wrong. I think it's easier to fix the former...

But also there should be a way to make round return an integer (e.g. passing `None` as 2nd argument)

----------
assignee: docs at python
components: Documentation, Interpreter Core
messages: 205647
nosy: JBernardo, docs at python
priority: normal
severity: normal
status: open
title: Round default argument for "ndigits"
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19933>
_______________________________________


More information about the New-bugs-announce mailing list