Mark Dickinson <dicki...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37000>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to