Ошибка атрибута: значение в Enum - PullRequest
0 голосов
/ 14 мая 2018

Почему в этом коде:

def conjugar_preterito_mais_que_perfeito_indicativo(word):
    """

    :param word: Verb to be conjugated
    :return: Conjugated verb in form of a dictionary
    """

    if not isinstance(word, str):
        return 'Entrada de dados incorreta | An incorrect input value'

    endings = ()

    if word.endswith('ar'):
        endings = enum_verbs_conjugator.TenseEndings.PRETERITO_MAIS_QUE_PERFEITO_ENDINGS_AR.value
    elif word.endswith('er'):
        endings = enum_verbs_conjugator.TenseEndings.PRETERITO_PERFEITO_ENDINGS_ER.value
    elif word.endswith('ir'):
        endings = enum_verbs_conjugator.TenseEndings.PRETERITO_MAIS_QUE_PERFEITO_ENDINGS_IR.value
    else:
        return 'A palavra não e um verbo | Not a verb'

    # is_irregular_verb = True if word in verb_persons_lists.irregular_verbs_list else False

    conjugated_forms = []
    final_conjugated_forms = dict()

    for ending in endings:
        conjugated_forms.append(word[:-2] + ending)
        conjugated_verbs_and_persons = zip(enum_verbs_conjugator.GrammaticalPersons.value, conjugated_forms)
        final_conjugated_forms = dict(conjugated_verbs_and_persons)
    return final_conjugated_forms

print(conjugar_preterito_mais_que_perfeito_indicativo('achar'))

Я получаю эту ошибку:

line 137, in conjugar_preterito_mais_que_perfeito_indicativo
conjugated_verbs_and_persons = zip(enum_verbs_conjugator.GrammaticalPersons.value, conjugated_forms)
File "/usr/lib/python3.6/enum.py", line 324, in __getattr__
raise AttributeError(name) from None
AttributeError: value

Я беру элементы из enum:

Похоже, мои перечисления не имеют значений. Это правильно? Я вижу, Python указывает на строку 324, но у меня не так много строк. Разве нельзя использовать его значение в функции zip ()? Что я делаю не так?

...