diff --git a/Doc/library/random.rst b/Doc/library/random.rst --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -71,17 +71,17 @@ Bookkeeping functions: -.. function:: seed([x]) +.. function:: seed(a=None) - 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 internal state of the random number generator. - If a :term:`hashable` object is given, deterministic results are only assured - when :envvar:`PYTHONHASHSEED` is disabled. + ``None`` or no argument seeds from current time or from an operating + system specific randomness source if available (see the :func:`os.urandom` + function for details on availability). + + If *a* is not ``None`` or an :class:`int` or :class:`long`, then + ``hash(a)`` is used instead. Note that the hash values for some types + are nondeterministic when :envvar:`PYTHONHASHSEED` is enabled. .. versionchanged:: 2.4 formerly, operating system resources were not used. diff --git a/Lib/random.py b/Lib/random.py --- a/Lib/random.py +++ b/Lib/random.py @@ -98,12 +98,14 @@ self.gauss_next = None def seed(self, a=None): - """Initialize internal state from hashable object. + """Initialize internal state of the random number generator. None or no argument seeds from current time or from an operating system specific randomness source if available. - If a is not None or an int or long, hash(a) is used instead. + If a is not None or is an int or long, hash(a) is used instead. + Hash values for some types are nondeterministic when the + PYTHONHASHSEED environment variable is enabled. """ if a is None: