-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecorators.py
More file actions
25 lines (21 loc) · 805 Bytes
/
Decorators.py
File metadata and controls
25 lines (21 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from typing import Callable
# The function which is converted to decorator using wrapper and nested function
def greetings(func) -> Callable:
def wrapper(movies_list):
print(f'Entering to {func.__name__}')
func(movies_list)
print(f'Exiting from {func.__name__}')
return wrapper
@greetings
def print_movies(movies_list: list[str]) -> None:
"""
function using greetings decorator
:param movies_list:
:return:
"""
for index, movie in enumerate(movies, start = 1):
print(f'{str(index).zfill(2)}. {movie}')
if __name__ == '__main__':
movies = ['The sixth sense', 'Fight club', 'Shutter island', 'Machinist', 'Seven', 'Black Swan',
'Vertigo', 'Perfect Blue', 'The Prestige', 'Insomnia', 'Midsommar']
print_movies(movies)