Decoration functions
-
For the first time in this resource, I wanted to ask you for help. I don't understand the subject with the decorators, but I have to do the job. That's the mission. Two lists (every the new line) are inserted from the words recorded through the gap. Available a function that converts these two lines into two lists of words and returns them lists. Determine the decorator for this function, which of these two lists forms a vocabulary where the keys are the words from the first list and the values relevant elements from the second list. Dictionary received I have to go back to call the decorator. Use the decorator for the first function and Call her. Result on the screen. I would appreciate your help.
-
I understand you need this:
# первоначальная функция def initial_func(text1, text2): return text1.split(), text2.split()
декоратор
def decor(func):
def decor_meat(text1, text2):
data = func(text1, text2)
return dict(zip(*data))return decor_meat
подключаем декоратор
initial_func = decor(initial_func)
использование декоратора
text1 = "key1 key2" #input('слова 1: ')
text2 = "value1 value2" #input('слова 2: ')print(initial_func(text1, text2))