04_Python — str, bytes, and the boundary between them¶
Level: 101 → 201 · for Python programmers
Python draws the text/bytes line as a type boundary and refuses to cross it silently. These lessons are what you already know about str and bytes, reorganised around chapter 2 and chapter 3, plus the places the boundary is easy to get wrong: open(), the errors policy, the bytes that are not text at all, normalization, and binary formats.
| # | Lesson | The question it answers | Status |
|---|---|---|---|
| 1 | str vs bytes |
Which is which, and why will Python not concatenate them? | stub |
| 2 | Encode, decode and errors | What do the eight errors= policies each throw away, and which one can be undone? |
written, 2026-09-07 |
| 3 | Bytes that are not text | How does os.listdir() hand me a filename that is not UTF-8, and hand it back unchanged? |
written, 2026-09-07 |
| 4 | Opening a file | Why is open(path) a bet, and what is the portable call? |
written, 2026-09-07 |
| 5 | Normalization | Why can 'é' == 'é' be False, and what do I run before comparing? |
written, 2026-09-06 |
| 6 | Bytes, hex and int | How do I read a binary format by hand with four conversions? | written, 2026-09-07 |
| 7 | A str in memory |
Why can one emoji quadruple what a string costs, and why is len() still O(1)? |
written, 2026-09-07 |