Created
March 18, 2021 15:49
-
-
Save megahomyak/442641ca3a3843c48c491c796b9600db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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