dimanche 21 juin 2020

How do I make a random number shared between instances?

import random

class Unique_Key(object):
def __init__(self):
    self.uni_k =random.randint(1, 1000000)
    


unique_key_obj1=Unique_Key()
print(f"First Record {unique_key_obj1.uni_k}")


unique_key_obj=Unique_Key()
print(f"Second Record {unique_key_obj.uni_k}")

Can someone please help me with how to make the value of the unique_key_obj1 object to be the same as that of the unique_key_obj object? Thanks!




Aucun commentaire:

Enregistrer un commentaire