I want to init id as a concatenation of phrase and type
from enum import Enum
from typing import NamedTuple
class WORD_TYPE(str, Enum):
APPROVED = 'approved'
FORBIDDEN = 'forbidden'
RISKY = 'risky'
class WordItem(NamedTuple):
phrase: str
type: WORD_TYPE
id: str = f'{phrase}_{type.name.lower()}'
so each time when I specify phrase and type I want to have an id automatically.
word_item = WordItem(phrase='phrase', type=WORD_TYPE.FORBIDDEN)
asssert word_item.id == 'phrase_forbidden'
What is the best way of doing that? Maybe there is some way of doing this using https://github.com/ericvsmith/dataclasses?
"WORD_TYPE"what type is this?