Cryptographically strong random numbers

Brian Gladman blindanagram at nowhere.net
Fri Oct 16 13:17:59 EDT 2015


On 16/10/2015 17:25, Steven D'Aprano wrote:
> Hello folks,

[snip detail]

> randbelow(end):
>     return a random integer in the half-open interval 0...end
>     (including 0, excluding end)
> 
> randint(start, end):
>     return a random integer in the closed interval start...end
>     (including both start and end)
> 
> randrange([start=0,] end [, step=1]):
>     return a random integer in the half-open range(start, stop, step)

I don't see the third option as being of much, if any, use. Either of
the first two would be fine.

Of these two, I personally prefer randbelow because it is consistent
with what I expect from ranges in Python (randint() always disappoints
me because it is inconsistent in this respect).




More information about the Python-list mailing list