The idea is to create a while loop that starts when a user enters "x" and ends when the user enters "y", and measures the time in between "x" and "y". I can't use key interrupt or anything like it because of limitations of my IDE. I would use something else but its what my school allows. What I need is a python built in timer that runs without being stopped by the user input prompt. I cannot use KeyboardInterrupt, I cannot import thread.
Asked
Active
Viewed 44 times
-2
-
So you want us to solve your school assignment? – Anton vBR May 21 '18 at 17:43
-
@SaR Have a look at this link https://docs.python.org/2/library/time.html – goks May 21 '18 at 17:45
-
@AntonvBR jesus, no. Im trying to create a storm calculator that times time between lighting strike and thunder sound, uses temp sensor and time with speed of sound equation and then spits out relative distance of storm. My only problem is that there are serious limitations with what I'm coding in, so I can't import most things and keyboardinterrupt doesn't work either. I also tried to prompt a user input, but it stops the loop meaning my timing feature stops as well. I need a timing method that can run in the background or a method to end the loop without stopping it while the user decide – SaR May 21 '18 at 17:49
-
@SaR No we are getting somewhere. You should post what you have tried, what is not permitted but works etc and ask for a workaround. – Anton vBR May 21 '18 at 17:51
-
Have you checked this: https://stackoverflow.com/questions/24072790/detect-key-press-in-python?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Anton vBR May 21 '18 at 18:01
1 Answers
0
Try using datetime to register each action
# x input
start = datetime.datetime.now()
# y input
end = datetime.datetime.now()
timedelta = end - start

Pedro Seda
- 36
- 4