Created
May 29, 2023 04:22
-
-
Save rongpenl/6144c7504ef7222ed759e465fdb0057c to your computer and use it in GitHub Desktop.
Cracking Intermediate Python Episode 1: Context Manager
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
from contextlib import contextmanager | |
from coach import Coach | |
@contextmanager | |
def activity_management(coach: Coach): | |
try: | |
coach.warm_up_players() | |
yield coach | |
finally: | |
coach.host_retro_meeting() | |
coach = Coach() | |
with activity_management(coach) as coach: | |
coach.coach_game() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment