fork download
  1. from enum import Enum
  2.  
  3. class Color(Enum):
  4. BLACK = ('black', '#000')
  5. WHITE = ('white', '#fff')
  6.  
  7. @property
  8. def name(self):
  9. return self.value[0]
  10.  
  11. @property
  12. def hex(self):
  13. return self.value[1]
  14.  
  15. print(Color.BLACK.name)
  16. print(Color.BLACK.hex)
Success #stdin #stdout 0.04s 9412KB
stdin
Standard input is empty
stdout
black
#000