Let’s say I have a loop that’ll take a while to finish, like reading a long file. How do I make it so every period of time, x (milliseconds?), I execute “some code”?
while inFile.readable():
line = inFile.readline()
print(line) # I want to do this every few seconds
I’d like to do this via threading and lambdas, as an exercise.
For example:
Can be done nicer with decorators or contexts, but you got the idea.