Python Forum
random module lacks instantiation - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/Forum-General)
+--- Forum: News and Discussions (https://python-forum.io/Forum-News-and-Discussions)
+--- Thread: random module lacks instantiation (/Thread-random-module-lacks-instantiation)



random module lacks instantiation - Skaperen - Dec-02-2019

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.


RE: random module lacks instantiation - ichabod801 - Dec-02-2019

>>> 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



RE: random module lacks instantiation - Skaperen - Dec-03-2019

now interleave r and s.


RE: random module lacks instantiation - ichabod801 - Dec-03-2019

That's on you.