Skip to content

Instantly share code, notes, and snippets.

@rongpenl
Created May 29, 2023 04:21
Show Gist options
  • Save rongpenl/bed54d8f961dedcf3c966fbccd3bb0c7 to your computer and use it in GitHub Desktop.
Save rongpenl/bed54d8f961dedcf3c966fbccd3bb0c7 to your computer and use it in GitHub Desktop.
Cracking Intermediate Python Episode 1: Context Manager
from typing import Callable
class Coach:
def warm_up_players(self):
print("The coach is warming up the players.")
def host_retro_meeting(self):
print("The coach is having a retro meeting after the game.")
def coach_game(self):
print("The game is in progress.")
def coach_exercise(self):
print("The exercise is in progress.")
def routine(self, activity: Callable):
self.warm_up_players()
activity()
self.host_retro_meeting()
if __name__ == "__main__":
coach = Coach()
coach.routine(coach.coach_game)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment