Save your work — this week your data survives when the script ends
Day 11 of 40
Week 2 was about control flow and lists — tools for making decisions and working with sequences of data. Every script you built was self-contained: when the script ended, all the data disappeared.
Week 3 changes that. You're learning two things that transform scripts into real tools:
By the end of this week, you'll have a Prompt Vault that remembers your AI video prompts across sessions. That's a real piece of tooling you can actually use at work.
Today is a Watch day — three Corey Schafer videos in sequence. Keep the [[Python Core Concepts — Reference Guide]] open in Obsidian as you watch. Focus on Section 4 (Sequence Types — dictionaries) and Section 8 (Error Handling — for the try/except you'll see at the end of the playlist).
Watch these three videos in order. Don't skip ahead — each one builds on the last. Type along with every example. The total runtime is about 60 minutes.
~15 minutes | Type along with everything
~25 minutes | Type along with everything
~20 minutes | Type along with everything
Have Cursor open next to each video. Every time Corey types code, you type it too — in a scratch file called day-11-notes.py. Don't just watch. If something doesn't make sense, pause and run the example yourself. The goal isn't to memorize everything; it's to build pattern recognition. You'll use these patterns in tomorrow's Jupyter session.
These are the ideas that matter most. Watch for them in all three videos.
A list is like a numbered row of boxes — you get to the data by position. A dictionary is like labeled drawers — you get to the data by name.
# List — access by position (fragile)
shot = [1, "Wide establishing", "Kling"]
print(shot[2]) # "Kling" — but only if you remember slot 2 is platform
# Dictionary — access by name (clear)
shot = {"scene": 1, "description": "Wide establishing", "platform": "Kling"}
print(shot["platform"]) # "Kling" — unambiguous
When your data has structure — a shot with multiple fields, a project with a name and client and scene count — use a dictionary. The label tells you (and anyone reading your code) exactly what the data means.
You will use these two patterns in every project that reads or writes files. Memorize them now.
# Read from a JSON file
import json
with open("data.json", "r") as f:
data = json.load(f)
# Write to a JSON file
with open("data.json", "w") as f:
json.dump(data, f, indent=2)
The with open(...) as f: pattern automatically closes the file when the indented block finishes — even if something goes wrong. You don't need to call f.close(). Always use with open.
"r" = read mode (file must already exist). "w" = write mode (creates the file or overwrites it). indent=2 makes the JSON file human-readable with 2-space indentation.
JSON (JavaScript Object Notation) is the format Python uses to save dictionaries and lists to files. It looks almost exactly like Python — just with a few small differences.
// JSON file: prompts.json
[
{
"platform": "Kling",
"shot": "Golf swing follow-through",
"prompt": "Cinematic slow motion, golden hour backlight"
},
{
"platform": "Runway",
"shot": "Ocean aerial",
"prompt": "Aerial tracking shot over turquoise waves"
}
]
Python's json.load() turns this file into a Python list of dictionaries. json.dump() turns a Python list of dictionaries back into a file like this. The conversion is seamless — JSON is just the on-disk representation of Python data.
These specific patterns will appear in every project for the rest of the course. When you see them in the videos, pause and type them out carefully:
shot = {} # start empty
shot["platform"] = "Kling" # add a key
shot["platform"] = "Runway" # update a key
del shot["platform"] # delete a key
"platform" in shot # check if key exists
import json
with open("file.json", "r") as f:
data = json.load(f)
with open("file.json", "w") as f:
json.dump(data, f, indent=2)
shot = {"scene": 1, "platform": "Kling", "type": "wide"}
for key in shot: # iterates over keys only
print(key)
for key, value in shot.items(): # iterates over key-value pairs
print(f"{key}: {value}")
with open ... json.load) from memorywith open ... json.dump) from memorywith open is better than manually calling f.close()You'll open Jupyter and run experiments with dictionaries and file I/O hands-on. You'll write to a JSON file, read it back, and see nested data structures in action. You'll also encounter the try/except FileNotFoundError pattern — the safety net that every file-reading script needs.