Skip to content

Commit

Permalink
bpo-40286: Put methods in correct sections. Add security notice to us…
Browse files Browse the repository at this point in the history
…e secrets for session tokens. (GH-19870)
  • Loading branch information
rhettinger authored May 5, 2020
1 parent 1e7e451 commit f01d1be
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,16 @@ Bookkeeping functions
the time :func:`getstate` was called.


.. function:: getrandbits(k)

Returns a Python integer with *k* random bits. This method is supplied with
the Mersenne Twister generator and some other generators may also provide it
as an optional part of the API. When available, :meth:`getrandbits` enables
:meth:`randrange` to handle arbitrarily large ranges.

.. versionchanged:: 3.9
This method now accepts zero for *k*.

Functions for bytes
-------------------

.. function:: randbytes(n)

Generate *n* random bytes.

This method should not be used for generating security tokens.
Use :func:`secrets.token_bytes` instead.

.. versionadded:: 3.9


Expand All @@ -145,6 +140,16 @@ Functions for integers
Return a random integer *N* such that ``a <= N <= b``. Alias for
``randrange(a, b+1)``.

.. function:: getrandbits(k)

Returns a Python integer with *k* random bits. This method is supplied with
the MersenneTwister generator and some other generators may also provide it
as an optional part of the API. When available, :meth:`getrandbits` enables
:meth:`randrange` to handle arbitrarily large ranges.

.. versionchanged:: 3.9
This method now accepts zero for *k*.


Functions for sequences
-----------------------
Expand Down

0 comments on commit f01d1be

Please sign in to comment.