Message206162
The docstring is better than the current doc as it says that the default precision is 0, without calling that the default for ndigits.
''' round(number[, ndigits]) -> number
Round a number to a given precision in decimal digits (default 0 digits).
This returns an int when called with one argument, otherwise the
same type as the number. ndigits may be negative.'''
---
Sidenote: To write round in Python, one could easily write
_sentinel = object
def round(number, ndigits=_sentinel):
if ndigits is _sentinel: ...
which makes ndigits positional-or-keyword, and almost optional-with-no-default, as _sentinel is close enough to being a default that cannot be passed in. This is a standard idiom. One who was really picky about having no default could use
def round(number, *args, **kwds): ...
and look for len(args) == 1 xor kwds.keys() == {'ndigits'}. |
|
Date |
User |
Action |
Args |
2013-12-14 02:18:07 | terry.reedy | set | recipients:
+ terry.reedy, mark.dickinson, r.david.murray, docs@python, JBernardo, vajrasky |
2013-12-14 02:18:07 | terry.reedy | set | messageid: <1386987487.54.0.8494253872.issue19933@psf.upfronthosting.co.za> |
2013-12-14 02:18:07 | terry.reedy | link | issue19933 messages |
2013-12-14 02:18:06 | terry.reedy | create | |
|