Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
16eb827b
Commit
16eb827b
authored
Sep 04, 2016
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve docs for random.seed()
parent
ab7b0a03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
Doc/library/random.rst
Doc/library/random.rst
+5
-2
Lib/random.py
Lib/random.py
+5
-3
No files found.
Doc/library/random.rst
View file @
16eb827b
...
@@ -63,8 +63,11 @@ Bookkeeping functions:
...
@@ -63,8 +63,11 @@ Bookkeeping functions:
If *a* is an int, it is used directly.
If *a* is an int, it is used directly.
With version 2 (the default), a :class:`str`, :class:`bytes`, or :class:`bytearray`
With version 2 (the default), a :class:`str`, :class:`bytes`, or :class:`bytearray`
object gets converted to an :class:`int` and all of its bits are used. With version 1,
object gets converted to an :class:`int` and all of its bits are used.
the :func:`hash` of *a* is used instead.
With version 1 (provided for reproducing random sequences from older versions
of Python), the algorithm for :class:`str` and :class:`bytes` generates a
narrower range of seeds.
.. versionchanged:: 3.2
.. versionchanged:: 3.2
Moved to the version 2 scheme which uses all of the bits in a string seed.
Moved to the version 2 scheme which uses all of the bits in a string seed.
...
...
Lib/random.py
View file @
16eb827b
...
@@ -96,11 +96,13 @@ class Random(_random.Random):
...
@@ -96,11 +96,13 @@ class Random(_random.Random):
None or no argument seeds from current time or from an operating
None or no argument seeds from current time or from an operating
system specific randomness source if available.
system specific randomness source if available.
For version 2 (the default), all of the bits are used if *a* is a str,
bytes, or bytearray. For version 1, the hash() of *a* is used instead.
If *a* is an int, all bits are used.
If *a* is an int, all bits are used.
For version 2 (the default), all of the bits are used if *a* is a str,
bytes, or bytearray. For version 1 (provided for reproducing random
sequences from older versions of Python), the algorithm for str and
bytes generates a narrower range of seeds.
"""
"""
if
a
is
None
:
if
a
is
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment