Created
May 29, 2023 04:21
-
-
Save rongpenl/bed54d8f961dedcf3c966fbccd3bb0c7 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 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