[Python Wpg] Tested seed()
high.res.mike at gmail.com
Thu Jun 28 11:40:38 CEST 2007
Richard Fillion wrote:
> You shouldn't pass a static value to a random seed generator. Pass
> something that will change, such as the current time, or date, or ...
> anything not-constant.
> Richard Fillion
> e: rick at centrix.ca
> p: 204.291.5800
We had a discussion about this at the meeting. If you leave out the "2"
the seed is based on the system time. I was curious if putting a
constant in the seed() function would return the same values each time
it's run. Nobody knew for sure. Nobody caught anything in the
documentation. Now we know.
Historically there are only two random generators I've seen which "self
seed". The first is the Apple// (which I discussed at the meeting) and
the second is an *old* PC card which got its seed from the amount of
static electricity in the air.
> On Jun 28, 2007, at 12:05 AM, Mike Pfaiffer wrote:
>> Here is some code.
>> from random import seed, randint
>> for c in range(10):
>> print c,randint(1,10)
>> Ran it twice under idle and the same results came out three times.
>> Looks like it is best to run it without a value in seed().
>> Here is what I got...
>> IDLE 1.2.1
>>>>> ================================ RESTART
>> 0 10
>> 1 10
>> 2 1
>> 3 1
>> 4 9
>> 5 8
>> 6 7
>> 7 4
>> 8 7
>> 9 7
>> Winnipeg mailing list
>> Winnipeg at python.org
> Winnipeg mailing list
> Winnipeg at python.org
More information about the Winnipeg