MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / take_enum_action

Function take_enum_action

example_code/item_009.py:158–167  ·  view source on GitHub ↗
(light)

Source from the content-addressed store, hash-verified

156 GREEN = "green"
157
158def take_enum_action(light):
159 match light:
160 case ColorEnum.RED: # Changed
161 print("Stop")
162 case ColorEnum.YELLOW: # Changed
163 print("Slow down")
164 case ColorEnum.GREEN: # Changed
165 print("Go!")
166 case _:
167 raise RuntimeError
168
169take_enum_action(ColorEnum.RED)
170take_enum_action(ColorEnum.YELLOW)

Callers 1

item_009.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected