Message71384
> In every case I can think of, I've wanted (0).numbits() to be 0.
Me too, in most cases, though I've encountered the occasional case where
raising ValueError would be more appropriate and would catch some bugs
that might otherwise pass silently.
So I agree that (0).numbits() should be 0, but I think there's enough
potential ambiguity that there should be a sentence in the documentation
making this explicit. Two of the most obvious (wrong) formulas for
numbits are: (1) numbits(n) = ceiling(log_2(n)), and (2) numbits(n) =
len(bin(n))-2, but neither of these formulas gives the right result for
0, or for negative numbers for that matter.
> The explanation in the docstring can probably be improved. What other
documentation is needed (where)?
The docstring looked okay to me. There should be more comprehensive
ReST documentation in the Doc/ directory somewhere, probably in
Doc/library/stdtypes.rst |
|
Date |
User |
Action |
Args |
2008-08-18 21:28:48 | mark.dickinson | set | recipients:
+ mark.dickinson, loewis, rhettinger, fredrikj |
2008-08-18 21:28:47 | mark.dickinson | set | messageid: <1219094927.84.0.457443911676.issue3439@psf.upfronthosting.co.za> |
2008-08-18 21:28:47 | mark.dickinson | link | issue3439 messages |
2008-08-18 21:28:46 | mark.dickinson | create | |
|