decorator - Py ii pre -pie Decorator

This commit is contained in:
fenix 2024-02-13 14:16:17 +01:00
parent 228eef0258
commit 11acf9073d
1 changed files with 12 additions and 0 deletions

12
quiet_night.py Normal file
View File

@ -0,0 +1,12 @@
from datetime import datetime
def not_during_the_night(func):
def wrapper():
if 7 <= datetime.now().hour < 22:
func()
else:
pass # Hush, the neighbors are asleep
return wrapper
def say_whee():
print("Whee!")