Author JBernardo
Recipients JBernardo, docs@python
Date 2013-12-09.04:24:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1386563060.5.0.176884779469.issue19933@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2013-12-09 04:24:20JBernardosetrecipients: + JBernardo, docs@python
2013-12-09 04:24:20JBernardosetmessageid: <1386563060.5.0.176884779469.issue19933@psf.upfronthosting.co.za>
2013-12-09 04:24:20JBernardolinkissue19933 messages
2013-12-09 04:24:19JBernardocreate