Skip to Content
Secret Recipes of the Python Ninja
book

Secret Recipes of the Python Ninja

by Cody Jackson
May 2018
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 37m
English
Packt Publishing
Content preview from Secret Recipes of the Python Ninja

How to do it...

  • SystemRandom class is the same as the random.SystemRandom class, that is, it provides random numbers and uses the best quality random seeding sources of the system.
  • choice(sequence) method also works just like the random.choice() method.
  • randbelow(n) function returns a random integer in the range [0, n).
  • randbits(k) method returns an integer with k random bits.
  • token_bytes([nbytes=None]) function returns a random byte string. If nbytes is not provided, a reasonable default is used; if provided, the returned string contains that many bytes.
  • token_hex([nbytes=None]) function returns a random text string in hex. The bytes used in the string are converted to two hex digits each.
  • token_urlsafe([nbytes=None]) function returns a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Expanding World of Python

The Expanding World of Python

Dane Hillard

Publisher Resources

ISBN: 9781788294874Supplemental Content