homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: round() has wrong argument names
Type: behavior Stage: patch review
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: chris.jerdonek, docs@python, ezio.melotti, mark.dickinson, python-dev
Priority: normal Keywords: easy, needs review, patch

Created on 2012年09月20日 16:47 by chris.jerdonek, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue-15985-1-branch-default.patch chris.jerdonek, 2012年09月20日 18:57 review
Messages (8)
msg170822 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012年09月20日 16:47
The documentation for round() says:
round(x[, n])
Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. Delegates to x.__round__(n).
(from http://docs.python.org/dev/library/functions.html#round )
However, we have the following:
Python 3.3.0rc2+ (default:1704deb7e6d7+, Sep 16 2012, 04:49:45) 
>>> round(x=4.7)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: Required argument 'number' (pos 1) not found
>>> round(number=4.7)
5
The second argument is also affected:
>>> round(5.1234, n=3)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: 'n' is an invalid keyword argument for this function
>>> round(5.1234, ndigits=3)
5.123
msg170823 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012年09月20日 16:50
A case where fixing the names improves both accuracy *and* readability!
msg170829 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012年09月20日 18:57
Here is a patch. Also, I checked, and there is already a test for the keyword arguments:
http://hg.python.org/cpython/file/dcced3bd22fe/Lib/test/test_builtin.py#l1239 
msg170835 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012年09月20日 19:36
Looks good to me.
msg170836 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012年09月20日 19:52
New changeset eccd94d4ee77 by Mark Dickinson in branch '3.2':
Issue 15985: fix round argument names in documentation. Thanks Chris Jerdonek.
http://hg.python.org/cpython/rev/eccd94d4ee77
New changeset ad04dd6c07f7 by Mark Dickinson in branch 'default':
Issue 15985: merge from 3.2.
http://hg.python.org/cpython/rev/ad04dd6c07f7 
msg170837 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012年09月20日 19:58
New changeset e4037dd73877 by Mark Dickinson in branch '2.7':
Issue 15985: fix round argument names in documentation. Thanks Chris Jerdonek.
http://hg.python.org/cpython/rev/e4037dd73877 
msg170838 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012年09月20日 19:59
Fixed. Thanks for the patch!
msg170839 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012年09月20日 20:01
Thanks for the quick commit, Mark. :)
History
Date User Action Args
2022年04月11日 14:57:36adminsetgithub: 60189
2012年09月20日 20:01:24chris.jerdoneksetmessages: + msg170839
2012年09月20日 19:59:14mark.dickinsonsetstatus: open -> closed
resolution: fixed
messages: + msg170838
2012年09月20日 19:58:04python-devsetmessages: + msg170837
2012年09月20日 19:52:20python-devsetnosy: + python-dev
messages: + msg170836
2012年09月20日 19:36:06mark.dickinsonsetmessages: + msg170835
2012年09月20日 18:57:02chris.jerdoneksetkeywords: + needs review, patch
files: + issue-15985-1-branch-default.patch
messages: + msg170829

stage: needs patch -> patch review
2012年09月20日 16:50:33mark.dickinsonsetnosy: + mark.dickinson
messages: + msg170823
2012年09月20日 16:48:44ezio.melottisetnosy: + ezio.melotti
2012年09月20日 16:47:53chris.jerdonekcreate

AltStyle によって変換されたページ (->オリジナル) /