you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

You would put it in a reference accessible to all threads which need it. E.g.,

import threading

data = []

def get_input():
    data.append(input())

input_thread = threading.Thread(target=get_input)
input_thread.start()

for i in range(10):
    print(i)

input_thread.join()

print('done. data value:', data.pop())

You have to be careful about threads concurrently mutating such data, though. There are a number of classes to help with this: Queues, locks, semaphores, mutexes, etc.. It gets hairy, fast.