This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def logging_decorator(func): | |
| def logging_wrapper(*args, **kwargs): | |
| print(f'Before {func.__name__}') | |
| func(*args, **kwargs) | |
| print(f'After {func.__name__}') | |
| return logging_wrapper | |
| @logging_decorator | |
| def sum(x, y): | |
| print(x + y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> def f(*, a, b): | |
| ... print(a, b) | |
| ... | |
| >>> f(1, 2) | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| TypeError: f() takes 0 positional | |
| arguments but 2 were given | |
| >>> f(a=1, b=2) | |
| 1 2 |
OlderNewer