[Python Wpg] Tested seed()

Richard Fillion rick at centrix.ca
Thu Jun 28 01:12:26 EDT 2007


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



On Jun 28, 2007, at 12:05 AM, Mike Pfaiffer wrote:

> 	Here is some code.
>
> #!/usr/bin/python
>
> from random import seed, randint
>
> seed(2)
> 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
>>>>
>
> 				Later
> 				Mike
>
> _______________________________________________
> Winnipeg mailing list
> Winnipeg at python.org
> http://mail.python.org/mailman/listinfo/winnipeg
>




More information about the Winnipeg mailing list