How to create enumeration (enum) programmatically in Python

1 Answer

0 votes
import enum      

Test = enum.Enum(         
            value='Test',         
            names=('python java php flag yes'),
            )


print('{}'.format(Test.yes))    
    
for e in Test:         
    print('{:7} = {}'.format(e.name, e.value))
 
 
      
'''
run:
  
Test.yes
python  = 1
java    = 2
php     = 3
flag    = 4
yes     = 5
 
'''

 



answered Apr 29, 2019 by avibootz
...