I'm trying to create a function that returns a 'pulse' every time it does something. The function must be passed as a callback if the person desires to receive the pulse. I'd like to print the pulses as new .
character in the same line, so I did this:
import time
def do_something(do=None):
while True:
time.sleep(1)
if do: do('.')
def prtn(text):
print(text, end=' ')
do_something(prtn)
but the code gets stuck and won't print anything!