On this page
  1. secrets.SystemRandom
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

secrets.SystemRandom

Prev: secrets.randbits | Up: secrets | Next: secrets.token_bytes
Rel: secrets.choice, secrets.compare_digest, secrets.randbelow, secrets.randbits
Ref: docs.python.org — secrets.SystemRandom
Tags: #public #python3 #stdlib #secrets


Import

import secrets
from secrets import SystemRandom

Signature & Overview

secrets.SystemRandom(x=None)

Alternate random number generator using sources provided by the operating system (such as /dev/urandom on Unix or CryptGenRandom on Windows).

Methods & Attributes

Usage

import secrets

rng = secrets.SystemRandom()
items = [1, 2, 3, 4]
rng.shuffle(items)
assert sorted(items) == [1, 2, 3, 4]

Gotchas

REPL Inspect

from secrets import SystemRandom
help(SystemRandom)

Linked from

Related notes