Screenshots are captured in a Docker container with a headless browser. Task: MIL-004#1 Task: MIL-004#2 Task: MIL-004#3 Task: MIL-004#4 Task: MIL-004#5
15 lines
834 B
Markdown
15 lines
834 B
Markdown
**English** · [Dansk](Lecture-5-Advanced-Decorators-da) · [Bahasa Melayu](Lecture-5-Advanced-Decorators-ms)
|
|
|
|
# Lecture 5: Advanced decorators
|
|
|
|

|
|
|
|
Code: `src/higher_lower/presentation/lectures/step_05_authenticated.py`.
|
|
|
|
## What we gained
|
|
|
|
- `*args` collects positional arguments and `**kwargs` collects keyword arguments, so a decorator works for any function.
|
|
- `is_authenticated` reads the user from the arguments and runs the function only when `user.is_logged_in` is true.
|
|
- A decorator can control whether a function runs at all, not only change its result.
|
|
- The same pattern protects any function that needs a logged-in user.
|