snakia.random

Classes

OSRandom()

A random number generator that uses the OS (cryptographically secure) to generate random bytes.

PythonRandom()

Random()

A random number generator.

class snakia.random.OSRandom[source]

Bases: Random[None]

A random number generator that uses the OS (cryptographically secure) to generate random bytes.

below(n)

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

Return type:

int

bits(k)[source]

Return k random bits.

Return type:

int

bytes(n)

Return n random bytes.

Return type:

bytes

choice(seq)

Return a random element from a non-empty sequence.

Return type:

TypeVar(T)

float()

Return a random float in the range [0.0, 1.0).

Return type:

float

get_state()[source]

Get the state of the random number generator.

Return type:

None

int(start, end)

Return a random int in the range [start, end].

Return type:

int

set_state(value)[source]

Set the state of the random number generator.

Return type:

None

shuffle(seq)

Shuffle a sequence in place.

Return type:

TypeVar(M, bound= MutableSequence[Any])

class snakia.random.PythonRandom[source]

Bases: Random[tuple[int, tuple[int, …], int | float | None]]

below(n)

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

Return type:

int

bits(k)[source]

Return k random bits.

Return type:

int

bytes(n)

Return n random bytes.

Return type:

bytes

choice(seq)

Return a random element from a non-empty sequence.

Return type:

TypeVar(T)

float()

Return a random float in the range [0.0, 1.0).

Return type:

float

get_state()[source]

Get the state of the random number generator.

Return type:

tuple[int, tuple[int, ...], int | float | None]

int(start, end)

Return a random int in the range [start, end].

Return type:

int

set_state(value)[source]

Set the state of the random number generator.

Return type:

None

shuffle(seq)

Shuffle a sequence in place.

Return type:

TypeVar(M, bound= MutableSequence[Any])

class snakia.random.Random[source]

Bases: ABC, Generic[S]

A random number generator.

final below(n)[source]

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

Return type:

int

abstract bits(k)[source]

Return k random bits.

Return type:

int

final bytes(n)[source]

Return n random bytes.

Return type:

bytes

final choice(seq)[source]

Return a random element from a non-empty sequence.

Return type:

TypeVar(T)

final float()[source]

Return a random float in the range [0.0, 1.0).

Return type:

float

abstract get_state()[source]

Get the state of the random number generator.

Return type:

TypeVar(S)

final int(start, end)[source]

Return a random int in the range [start, end].

Return type:

int

abstract set_state(value)[source]

Set the state of the random number generator.

Return type:

None

final shuffle(seq)[source]

Shuffle a sequence in place.

Return type:

TypeVar(M, bound= MutableSequence[Any])

Modules

os

python

random