TelenkovDmitry 3 ay önce
ebeveyn
işleme
6d8c62ab65
1 değiştirilmiş dosya ile 31 ekleme ve 4 silme
  1. 31 4
      courses/python_func/decorator.py

+ 31 - 4
courses/python_func/decorator.py

@@ -27,10 +27,20 @@ def decorator(func):
         print('Заканчиваем декоратор')
     return inner
 
-@decorator
-def say_hello_to(name, surname):
-    print('hello', name, surname)
 
+def decorator_2(func):
+    def inner(*args, **kwargs):
+        print('Стартуем декоратор')
+        func_res = func(*args, **kwargs)
+        print(f'Функция func вернула значение "{func_res}"')
+        print('Заканчиваем декоратор')
+        return func_res.swapcase()
+    return inner
+
+
+@decorator_2
+def say_hello_to(name, surname):
+    return f'Hello {name} {surname}'
 
 
 decorator
@@ -38,8 +48,25 @@ def my_func():
     print('This is my mega function!')
 
 
+def header_h1(func):
+    def inner(*args, **kwargs):
+        result = func(*args, **kwargs)
+        return f'<h1>{result}</h1>'
+    return inner
+
+@header_h1
+def one_more_func(name, surname):
+    return f'Hello {name} {surname}'
+
+
 def main():
-    say_hello_to('Vasya', 'Ivanov')
+    # res = say_hello_to('Vasya', 'Ivanov')
+    # print(f'{res=}')
+
+    res = one_more_func("gennadi", "LOSKOV")
+    print(f'{res=}')
+   
+   
 
 
 if __name__ == '__main__':