Is it necessary to call seed() when using random in Python?
Question: I was looking at the following code:

    
    
    from random import choice
    
    for val in range(10):
        a = ','.join(str(choice(range(20))) for idx in range(4))
        print a
    

And realized that I hadn't used seed(). I've been taught to seed the random
number generator if you intend to generate different psuedo-random sequences.

I decided to run the code, expecting to the sequence repeated each time. But
after several runs of the code, it appears to generate a different sequence
each time.

  1. Is it really necessary to seed the Python random number generator? or...
  2. Is seed being called by default somewhere? or...
  3. Am I doing something wrong and/or don't understand what's happening?


Answer: I think seed is just meant to be used

1) so that you can get the same predictable sequence every time if you seed
with the same number

2) to feed a better (eg hardware generated) random number in as a start value

