+ 3

Python loops with time interval

Is it possible to loop a code , for example a password generator with time interval? So that it could act like Google Authenticator.

10th Jul 2019, 3:38 AM
Ayush Gupta
Ayush Gupta - avatar
5 ответов
+ 1
Not for Python but have used similar functions in C. Here is the link from the Python documentation( https://docs.python.org/3/library/time.html#module-time ). It states that the function availability is dependent on your Python version. Something in here should be able to help you be more precise in the time calculation instead of trying to just create a loop to simulate a time delay.
10th Jul 2019, 1:49 PM
Robb
+ 1
There is a time module with functions that you can use to handle tracking time or possibly using the sleep function dependent on how you want to design it.
10th Jul 2019, 1:29 PM
Robb
+ 1
Robb , have you ever used it yourself? Thanks for replying though
10th Jul 2019, 1:33 PM
Ayush Gupta
Ayush Gupta - avatar
+ 1
You can also use the builtin threading library to schedule repeated action in python, like write a function that calls itself after a certain amount of time. A simple example is here: https://stackoverflow.com/questions/8600161/executing-periodic-actions-in-python
11th Jul 2019, 5:50 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Thank you very much Tibor !
11th Jul 2019, 7:01 AM
Ayush Gupta
Ayush Gupta - avatar