Message343305
Related:
`randrange(0)` raises an exception
`choice([])` raises an exception
Those are very different from `getrandbits(0)`: in both cases there's no reasonable value that can be returned: for the first case, there's no integer `x` with `0 <= x < 0`; for the second, there's no element of `[]`, period. In contrast, there's an obvious, valid, return value for `getrandbits(0)`.
The `getrandbits(0)` example is much more similar to `randrange(1)` (in fact, it's pretty much the same thing: apart from `n = 0`, `getrandbits(n)` is equivalent at some level to `randrange(2**n)`.
So if `getrandbits(0)` should be an exception on the basis of not having any randomness in the result, then `randrange(1)` should be an exception on the same basis, as should `random.uniform(2.0, 2.0)`, etc.
So to me, it makes no sense at all that `getrandbits(0)` raises: I can't see any good reason for it to do so. |
|
Date |
User |
Action |
Args |
2019-05-23 15:47:29 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, Mathis Hammel |
2019-05-23 15:47:29 | mark.dickinson | set | messageid: <1558626449.4.0.757565923506.issue37000@roundup.psfhosted.org> |
2019-05-23 15:47:29 | mark.dickinson | link | issue37000 messages |
2019-05-23 15:47:29 | mark.dickinson | create | |
|