12 def get_instance(name):
13 if Random.__instance is None:
15 return Random.__instance
17 def __init__(self, name):
18 if Random.__instance is not None:
19 raise Exception("This class is a singleton!")
26 Random.__instance = self
29 if self.name == SECRETS:
31 self.engine.seed(seed)
33 def randint(self, a, b):
35 if self.name == RANDOM:
36 return self.engine.randint(a, b)
37 return a + self.engine.randbelow(b - a + 1)
39 def choice(self, seq):
40 return self.engine.choice(seq)
42 def uniform(self, a, b):
44 if self.name == RANDOM:
45 return self.engine.uniform(a, b)
46 return self.engine.SystemRandom().uniform(a, b)