Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/usr/local/bin/python3.6
  2.  
  3. def init_hr():
  4. number = 0
  5. def inner():
  6. nonlocal number
  7. number += 1
  8. print("============================================================================")
  9. print("============================== UEBUNG ", number, "===================================")
  10. print("============================================================================")
  11. print()
  12. print()
  13. return inner
  14.  
  15. hr = init_hr()
  16. hr()
  17. hr()
  18. hr()
  19.  
  20. # Kind of decorator, although it changes the interface of the function
  21.  
  22. def call_with_sequence_of_numbers(func):
  23. number = 0
  24. def wrapper():
  25. nonlocal number
  26. number += 1
  27. func(number)
  28. return wrapper
  29.  
  30. @call_with_sequence_of_numbers
  31. def print_headline(number):
  32. print("============================================================================")
  33. print("============================== UEBUNG ", number, "===================================")
  34. print("============================================================================")
  35. print()
  36. print()
  37.  
  38. print_headline()
  39. print_headline()
  40. print_headline()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement