Week 10 of 16

Week 10 Review & Halfway Milestone

Wrap up error handling and logging — then celebrate: you're halfway through the course

Day 50 45 minutes Review

Day 50 of 80

You're Halfway There

Day 50 of 80. That's not nothing. You started this course not knowing Python. Now you're writing multi-file apps with object-oriented design, custom exception hierarchies, structured logging, a REST API with Flask, and Claude AI integration.

Stop for a moment and recognize what you've built. This isn't a toy. It's a working, professional-structure application that does something real. Half of all people who start coding courses quit before week 4. You're on week 10.

The Real Milestone

Halfway through the calendar is nice. But the real milestone is this: you're now writing Python that most beginners never reach. Custom exceptions, structured logging, object-oriented design — these are patterns used in production software at real companies. You got here.

Week 10 Milestone Check

Before moving on, confirm you can do all four of these from memory (or nearly so):

1. Write try/except/else/finally blocks

You know what each part does: try is the risky code, except handles specific failure types, else runs only on success, finally always runs for cleanup. You can catch multiple exception types in one block or chain multiple except clauses for different error types.

2. Create custom exception classes

You created PromptVaultError as a base class, with InvalidPlatformError and EmptyFieldError as specific subtypes. Each stores structured data (not just a message string) in instance attributes. Calling code can catch specific types or the base class for a catch-all.

3. Set up Python's logging module

You created a get_logger(name) factory in logger.py that sets up both a file handler (DEBUG+) and a console handler (WARNING+). Any module can call get_logger(__name__) and get a fully configured logger. The logs/ directory is created automatically.

4. Add logging throughout an existing codebase

You instrumented every meaningful operation in vault.py: INFO for normal operations (added, loaded, deleted), WARNING for recoverable failures (bad index), ERROR for actual failures (corrupt JSON, write error), and DEBUG for fine-grained detail (save confirmations, search result counts).

Your Project Now Has

Take stock of everything the Prompt Vault includes at this point:

The only thing a real production app has that you don't yet have is a proper database. That's Week 11.

Quick Self-Test

Without looking at your code, can you answer these? If not, that's your review target:

Question Answer
What's the difference between except ValueError and except Exception? First catches only ValueError; second catches almost everything. Too broad = hides bugs.
When does the else block in a try/except run? Only when no exception was raised in the try block.
What does if not logger.handlers prevent? Adding duplicate handlers if get_logger is called more than once with the same name.
What log level goes to the console in your app? WARNING and above. DEBUG and INFO go to the file only.
Why call super().__init__(message) in a custom exception? So the exception has a string representation when printed or used in f-strings.

Week 11 Preview: Databases with SQLite

Your JSON file works, but it has real limitations:

Databases solve all of this. Week 11 introduces SQLite — a database that lives in a single file, needs no server, and is built into Python with import sqlite3. You'll learn basic SQL, build a Database class, and write a migration script to move your existing JSON data into SQLite.

SQL is a Separate Language

SQL (Structured Query Language) is not Python. It's a domain-specific language for asking questions about data. It looks like: SELECT * FROM prompts WHERE platform = 'Kling' ORDER BY created_at DESC. It's simple enough to learn the basics in one week, and it's one of the most valuable skills in software development. You'll use SQL for the rest of your career.

End of Day Checklist

Day 51

Watch day. Two videos: Corey Schafer's SQLite tutorial and freeCodeCamp's SQL intro. You'll learn the four SQL commands you actually need: SELECT, INSERT, DELETE, and WHERE. No server to install, no complex setup — just import sqlite3 and you're ready.