Python Forum

Full Version: random module lacks instantiation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i don't see any way to make instances of the random module main class. when re-running sequences from the original seed, this makes it easy to have 2 or more sequences of the same, or different, seeds. it also can allow making parallel (such as with threads) initial runs of a seed sequence. the interface should be simple and obvious. just create a new instance and it will have all the same attributes and methods. how that's implemented, i have no idea.
>>> import random
>>> r = random.Random()
>>> r.seed(801)
>>> r.random()
0.10513447378227592
>>> r.random()
0.3553035267725949
>>> s = random.Random()
>>> s.seed(801)
>>> s.random()
0.10513447378227592
>>> s.random()
0.3553035267725949
now interleave r and s.
That's on you.