Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime
- class TimeManager:
- def __init__(self):
- self.time_in = datetime.now()
- self.time_out = datetime.now()
- def __enter__(self):
- self.delta = self.time_in - self.time_out
- return self.time_in, self.time_out, self.delta
- def __exit__(self, exc_type, exc_val, exc_tb):
- pass
- with TimeManager() as a:
- print(a[0].strftime("%Y-%m-%d-%H.%M.%S"))
- print(a[1].strftime("%Y-%m-%d-%H.%M.%S"))
- print(a[2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement