I'm implementing a loop that should continue until a user presses the Return key following the instructions on this page i got this to work:
def _input_thread_2( L ):
raw_input()
L.append( None )
#### test _input_thread()
L = []
thread.start_new_thread(_input_thread_2, (L, ))
while True:
time.sleep(1)
print "\nstill going..."
if L:
break
My question is why the following seemingly simple adaptation doesn't work? Instead of exiting the loop upon pressing a key, it just keeps looping:
def _input_thread_3( keep_going ):
"""
Input: doesn't matter
Description - When user clicks the return key, this changes the input to the False bool.
"""
raw_input()
keep_going = False
#### test _input_thread()
keep_going = True
thread.start_new_thread(_input_thread_3, (keep_going, ) )
while True:
time.sleep(1)
print "\nstill going..."
if not keep_going:
break
Can you help me understand the difference between these?