The code is self explanatory:
Python 3 Source Code:
———————————————-
from threading import Timer # import the Timer class
import os # import os library
import time # import time library
def main(): # define the main function
os.system(“cls”) # Windows: Clear the console (Remove last printout)
print(“Time: “+time.ctime(time.time())) # Display the time
t = Timer(1,main) # Instantiate the Timer() object with 1 sec interval — Recursive
t.start() # Start the timer
if __name__ == “__main__”: # Check if the script is being executed from console
main() # Start the program
———————————————-
It displays a clock on Windows Command Prompt and updates it every second. It mainly demonstrates the Timer object of threading library.