Practice ยท 3 of 3
Reusable context manager
Implement class Timer usable as a context manager AND reusable across runs:
- with Timer() as t: โ on exit, t.elapsed is a float โฅ 0 seconds
- t.runs counts completed blocks
- nested usage of two Timers must be independent
- entering must return the timer itself
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Custom Container Practice