I am using a random.Random() object in order to have a seeded random generator throughout all parts of a large project. Most of the time I just want the seeded random generator, but at some points I would like to have the seed to display it to the user. I would preferably not have to pass the seed throughout the entire project as well...is there any way to retrieve the seed from a random object? I have tried looking in the library source code on my computer and looking it up, but I can't find anything. Anyone know how I can get it? I am not just referring about the random.random number function like shown in this question, I am using the random.Random() class.
I have tried using random.seed() or random.seed but those don't work. I define a random generator at the start of my program using
from random import Random
seed = #seed
randomGenerator = Random(seed)
I then pass the randomGenerator object into a bunch of classes I use for the project. But I can't seem to find a way to get the random seed out. It must be possible since within the random library it is able to generate random numbers based on the seed, so is there any workaround to retrieve it?
Aucun commentaire:
Enregistrer un commentaire