Python Forum
random module lacks instantiation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
random module lacks instantiation
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
>>> 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
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
now interleave r and s.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
That's on you.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  doc for os.stat() lacks exceptions Skaperen 1 2,616 Feb-21-2021, 09:25 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020