Level 3 / Project 09 - Reusable Utils Library¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| — | This project | — | — | Flashcards | — | Browser |
Estimated time: 45 minutes
Focus¶
- common helper functions and reuse
Why this project exists¶
This project gives you level-appropriate practice in a realistic operations context. Goal: run the baseline, alter behavior, break one assumption, recover safely, and explain the fix.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-3/09-reusable-utils-library
python project.py slugify "Hello World!"
python project.py convert my_variable_name --to camel
python project.py validate user@example.com --type email
pytest -q
Expected terminal output¶
Expected artifacts¶
- Utility outputs on stdout
- Passing tests
- Updated
notes.md
Checkpoint: Baseline code runs and all tests pass. Commit your work before continuing.
Alter it (required) — Extension¶
- Add a
deep_flattenfunction that flattens arbitrarily nested lists. - Add a
validate_phonefunction similar tovalidate_email. - Add a
pluralizestring utility (simple English rules: "cat" -> "cats").
Break it (required) — Core¶
- Call
chunkwith size 0 — what happens? - Call
slugifywith only special characters — what is returned? - Call
camel_to_snakeon an already-snake string — is the result correct?
Fix it (required) — Core¶
- Ensure
chunkraises a clear error for non-positive sizes. - Handle edge case where
slugifyproduces an empty string. - Add idempotency:
camel_to_snake(snake_to_camel(x))should round-trip.
Checkpoint: All modifications done, tests still pass. Good time to review your changes.
Explain it (teach-back)¶
- What makes a function "reusable" vs. tightly coupled to one project?
- Why write docstrings with input/output examples?
- How does
re.subwork for text transformation? - Why use
set()inunique_orderedfor O(1) membership checking?
Mastery check¶
You can move on when you can: - design small, composable utility functions, - write clear docstrings with examples, - test edge cases and boundary conditions, - use regex for text transformation.
Related Concepts¶
- Errors and Debugging
- Files and Paths
- Functions Explained
- How Imports Work
- Quiz: Errors and Debugging
| ← Prev | Home | Next → |
|---|---|---|