Python's random seems are global, so modules changing it will effect each other.
While there are of course many 3rd party modules, is there a way using Python's standard library to have a random number local to a context.
(without using random.get/setstate
which may be problematic when mixing code from different modules).
Something like...
r = random.context(seed=42)
number = r.randint(10, 20)
Where each module can use its own random context.
Aucun commentaire:
Enregistrer un commentaire