Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3.6
- def init_hr():
- number = 0
- def inner():
- nonlocal number
- number += 1
- print("============================================================================")
- print("============================== UEBUNG ", number, "===================================")
- print("============================================================================")
- print()
- print()
- return inner
- hr = init_hr()
- hr()
- hr()
- hr()
- # Kind of decorator, although it changes the interface of the function
- def call_with_sequence_of_numbers(func):
- number = 0
- def wrapper():
- nonlocal number
- number += 1
- func(number)
- return wrapper
- @call_with_sequence_of_numbers
- def print_headline(number):
- print("============================================================================")
- print("============================== UEBUNG ", number, "===================================")
- print("============================================================================")
- print()
- print()
- print_headline()
- print_headline()
- print_headline()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement