Skip to content

Instantly share code, notes, and snippets.

@W4RH4WK
Last active December 6, 2015 12:11
Show Gist options
  • Select an option

  • Save W4RH4WK/44c5e26da2944be0ddbf to your computer and use it in GitHub Desktop.

Select an option

Save W4RH4WK/44c5e26da2944be0ddbf to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from datetime import datetime, timedelta
from time import sleep
def time_mark(**timedelta_kwargs):
mark = datetime.now() + timedelta(**timedelta_kwargs)
while True:
yield datetime.now() > mark
if __name__ == '__main__':
# create generator
are_we_there_yet = time_mark(seconds=3)
# annoying kid
for i in range(5):
print(next(are_we_there_yet))
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment