[ python-Bugs-901605 ] random.seed not initialized as advertised
SourceForge.net
noreply at sourceforge.net
Sat Feb 21 02:39:50 EST 2004
Bugs item #901605, was opened at 2004-02-21 00:45
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=901605&group_id=5470
Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: paul rubin (phr)
Assigned to: Nobody/Anonymous (nobody)
Summary: random.seed not initialized as advertised
Initial Comment:
The doc for random.seed(x) says: Optional argument x
can be any 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.
In fact the random module calls the seed function with
x=None when a Random object is instantiated, not with
the current system time as the docs indicate. You can
tell this by doing something like:
import random
class myrand(random.Random):
def seed(x):
print x
random.Random.seed(x)
a = myrand()
and you'll see it prints None. Initializing with None
may be reasonable behavior, but it doesn't match the
docs. So either the code or the doc should be updated.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2004-02-21 02:39
Message:
Logged In: YES
user_id=31435
The docs are correct. They say that calling seed() with no
argument is the same as calling seed(None), and that's true,
and it's also true that both cases end up using current
system time. That happens because the implementation of
seed() special-cases argument None, but the docs describe
behavior, not implementation details.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=901605&group_id=5470
More information about the Python-bugs-list
mailing list