3 ms·
Python lets you instantiate Random objects with a pre-set seed, so you don't have to risk doing anything that might affect the global state. Try this at an inte
by simonw 17y ago
Python lets you instantiate Random objects with a pre-set seed, so you don't have to risk doing anything that might affect the global state. Try this at an interactive prompt:
import random
r = random.Random("myseed")
r.random()
r.random()
r.random()
r2 = random.Random("myseed")
r2.random()
r2.random()
r2.random()
Both sequences of random numbers will be the same.
- stakent 17y agoYou are perfectly right. I was talking about source of patio11's problem which arose from modifying global state.