Files
055-higher-lower/docs/wiki/Lecture-4-Decorators.md
Tirsvad 1887fc347f Add lecture screenshots, README step overview and the three-language wiki
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
2026-11-06 12:42:20 +08:00

15 lines
743 B
Markdown

**English** · [Dansk](Lecture-4-Decorators-da) · [Bahasa Melayu](Lecture-4-Decorators-ms)
# Lecture 4: Decorators
![The route /bye in bold, emphasised and underlined text](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/055-higher-lower/raw/branch/main/docs/screenshots/lecture-4-decorators.png)
Code: `src/higher_lower/presentation/lectures/step_04_decorators.py`.
## What we gained
- A decorator is a function that takes a function and returns a new function.
- `make_bold`, `make_emphasis` and `make_underlined` add `<b>`, `<em>` and `<u>` once, so no route repeats the tags.
- Decorators stack: the one nearest the function runs first.
- `functools.wraps` keeps the name of the function, which Flask needs for every route.