random

native module

Seedable non-cryptographic PRNG. import "random". For security use crypto.secure_random.

random.seed(n: int)

Seed the global RNG for reproducibility.

random.int(max: int) => int

Random int in [0, max) (requires max > 0).

random.int_range(lo, hi: int) => int

Random int in [lo, hi).

random.float() => float

Random float in [0.0, 1.0).

random.bool() => bool

Random boolean.

random.bytes(n: int) => string

n random bytes packed in a string (non-crypto).

random.choice(list) => any

Uniformly-random element of a non-empty list.

random.shuffle(list) => list

Fisher-Yates shuffle in place; returns the list.

random.uuid() => string

Random v4 UUID string.

On this page