Skip to content

Instantly share code, notes, and snippets.

@megahomyak
Created March 18, 2021 15:49
Show Gist options
  • Save megahomyak/442641ca3a3843c48c491c796b9600db to your computer and use it in GitHub Desktop.
Save megahomyak/442641ca3a3843c48c491c796b9600db to your computer and use it in GitHub Desktop.
import time
class Sleepy(type):
def __getitem__(cls, value):
if isinstance(value, slice):
if value.step is None:
# start:stop
# minutes:seconds
time.sleep(value.start * 60 + value.stop)
else:
# start:stop:step
# hours:minutes:seconds
time.sleep(value.start * 60 * 60 + value.stop * 60 + value.step)
else:
time.sleep(value)
class sleep(metaclass=Sleepy):
pass
sleep[10:00]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment