So I'm trying to achieve something like this
from enum import Enum
tabulate_formats = ['fancy_grid', 'fancy_outline', 'github', 'grid']
class TableFormat(str, Enum):
for item in tabulate_formats:
exec(f"{item} = '{item}'")
Though i get this error
Traceback (most recent call last):
File "/app/src/main.py", line 25, in <module>
class TableFormat(str, Enum):
File "/app/src/main.py", line 26, in TableFormat
for item in tabulate_formats:
File "/usr/local/lib/python3.6/enum.py", line 92, in __setitem__
raise TypeError('Attempted to reuse key: %r' % key)
TypeError: Attempted to reuse key: 'item'
How do I properly assign them into the class