How to use Python's random number generator with a local seed?
The functions supplied by this module are actually bound methods of a hidden instance of the
random.Random
class. You can instantiate your own instances ofRandom
to get generators that don’t share state.
Make your own random.Random
instance and use that.
rng = random.Random(42)number = rng.randint(10, 20)