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
834 B
834 B
English · Dansk · Bahasa Melayu
Lecture 5: Advanced decorators
Code: src/higher_lower/presentation/lectures/step_05_authenticated.py.
What we gained
*argscollects positional arguments and**kwargscollects keyword arguments, so a decorator works for any function.is_authenticatedreads the user from the arguments and runs the function only whenuser.is_logged_inis 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.
