According to the documentation of Random library, assuming the developer does not provide any seed(None) the function uses the system current time as a seed(time.time()).
Unfortunately, it seems the output doe not reflects the documentation
print(random.randrange(1,10))
a=time.time()
.
.
.
.
random.seed(a)
print(random.randrange(1,10))
The code above produces 2 different outputs so assuming I use windows 10(for those who might think in the direction of urandom supplier) and Python 3 my questions are:
- Why the above code does not produces the same output
- When I tried to find the seed assignment part in Random.py I couldn't find anywhere time.time() assignment to Random.seed so ID someone can refers to that part I will be grateful
Aucun commentaire:
Enregistrer un commentaire