Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- class Clock(object):
- def __init__(self):
- self.myTime = time.time()
- def tick(self, secs=1):
- while time.time() <= secs + self.myTime:
- pass
- self.myTime = time.time()
- def main():
- myClock = Clock()
- for i in xrange(10):
- z = time.time()
- print z,'\t', i*0.25,
- time.sleep(i*0.25)
- myClock.tick()
- print '\t', time.time(), '\t', time.time() - z
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment