The below code attempts to illustrate what I want. I basically want two instances of "random" that operate independently of each other. I want to seed "random" within one class without affecting "random" in another class. How can I do that?
class RandomSeeded:
def __init__(self, seed):
import random as r1
self.random = r1
self.random.seed(seed)
def get(self):
print self.random.choice([4,5,6,7,8,9,2,3,4,5,6,7,])
class Random:
def __init__(self):
import random as r2
self.random = r2
self.random.seed()
def get(self):
print self.random.choice([4,5,6,7,8,9,2,3,4,5,6,7,])
if __name__ == '__main__':
t = RandomSeeded('asdf')
t.get() # random is seeded within t
s = Random()
s.get()
t.get() # random should still be seeded within t, but is no longer