For example, let's say I have this "pseudo" code here:
def on_start():
members = {'guy1':'1234','guy2':'5678'}
def function1():
# we do something with the dict, let's say, print each member
print(members.keys())
# ex: new_member = {'guy3':'9012'}
def function2(new_member):
# something happened so the dict now has a new member
members.update(new_member)
on_start()
while True:
function1() # run on a separate thread
# the condition would be "if I triggered the "add_member" event, do function2
if condition:
function2(input())
I basically have a function that is called upon the script's startup, which initializes the dictionary, and then there's function1()
that loops and uses that dictionary, and if a new member is added from user input, then function2()
is called which should add the member to the dict, so the next time function1()
is called, it will find that newly added member.
How can I achieve this ?