summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-09-07 00:38:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-09-07 00:38:15 (GMT)
commitf763a728adf45926bd75fc6a499eefa4d845b683 (patch)
tree34208612863bd29e798d45a08872364b5456c233 /Doc
parent435cb0f23304d57b0cafb2a4449a41150f7fffa9 (diff)
downloadcpython-f763a728adf45926bd75fc6a499eefa4d845b683.zip
cpython-f763a728adf45926bd75fc6a499eefa4d845b683.tar.gz
cpython-f763a728adf45926bd75fc6a499eefa4d845b683.tar.bz2
Document which part of the random module module are guaranteed.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/random.rst23
1 files changed, 14 insertions, 9 deletions
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 6ef5d20..270518c 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -51,18 +51,23 @@ from sources provided by the operating system.
Bookkeeping functions:
-.. function:: seed([x])
+.. function:: seed([x], version=2)
- Initialize the basic random number generator. Optional argument *x* can be any
- :term:`hashable` object. If *x* is omitted or ``None``, current system time is used;
- current system time is also used to initialize the generator when the module is
- first imported. If randomness sources are provided by the operating system,
- they are used instead of the system time (see the :func:`os.urandom` function
- for details on availability).
+ Initialize the random number generator.
- If *x* is not ``None`` or an int, ``hash(x)`` is used instead. If *x* is an
- int, *x* is used directly.
+ If *x* is omitted or ``None``, the current system time is used. If
+ randomness sources are provided by the operating system, they are used
+ instead of the system time (see the :func:`os.urandom` function for details
+ on availability).
+ If *x* is an int, it is used directly.
+
+ With version 2 (the default), a :class:`str`, :class:`bytes`, or :class:`bytearray`
+ object gets converted to a :class:`int` and all of its bits are used. With version 1,
+ the :func:`hash` of *x* is used instead.
+
+ .. versionchanged:: 3.2
+ Moved to the version 2 scheme which uses all of the bits in a string seed.
.. function:: getstate()