dec.py 543 B

123456789101112131415161718
  1. def my_decorator(function_to_decorate):
  2. def the_wrapper_around_the_original_function():
  3. print("Этот код работает до вызова функции")
  4. function_to_decorate()
  5. print("Этот код работает после вызова функции")
  6. return the_wrapper_around_the_original_function
  7. def stand_alone_function():
  8. print("Эта функция не изменяется")
  9. @my_decorator
  10. def another_stand_alone_function():
  11. print("Оставль меня в покое")
  12. another_stand_alone_function()