MCPcopy Index your code
hub / github.com/python/cpython / randbelow

Function randbelow

Lib/secrets.py:25–29  ·  view source on GitHub ↗

Return a random int in the range [0, n).

(exclusive_upper_bound)

Source from the content-addressed store, hash-verified

23choice = _sysrand.choice
24
25def randbelow(exclusive_upper_bound):
26 """Return a random int in the range [0, n)."""
27 if exclusive_upper_bound <= 0:
28 raise ValueError("Upper bound must be positive.")
29 return _sysrand._randbelow(exclusive_upper_bound)
30
31DEFAULT_ENTROPY = 32 # number of bytes to return by default
32

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…