Last active
June 14, 2022 13:41
-
-
Save pointofpresence/726963a29ed0ba6afb0dfd855df98d65 to your computer and use it in GitHub Desktop.
Python: Enum with strings
This file contains hidden or 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
| # A better practice is to inherit Signal from str: | |
| class Signal(str, Enum): | |
| red = 'red' | |
| green = 'green' | |
| orange = 'orange' | |
| brain_detected_colour = 'red' | |
| brain_detected_colour == Signal.red # direct comparison |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment