Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import time
- class Timer:
- def __init__(self, **kwargs):
- self._time = kwargs.get('starting_time', 0)
- def _count(self):
- while True:
- self._time += 1
- time.sleep(1)
- def start(self):
- t = threading.Thread(target=self._count)
- t.start()
- return t
- @property
- def current(self):
- return self._time
- # Create timer that starts counting from 0
- timer = Timer()
- #Create timer that starts counting from any input number
- timer = Timer(5)
- # Start the timer counting
- timer.start()
- # Get current timer time
- timer.current
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement