Running Scripts in VS Code
- ▸Recognise the four command-line patterns used in the course
- ▸Run any script from the VS Code integrated terminal
- ▸Use --help to discover what a script needs
- ▸Debug a script with breakpoints and the Run button confidently
This page walks you through running every kind of script you will meet in the course — from a plain "no arguments" script to ones that need --prompt, --image, or multiple subcommands. Once you understand these four patterns you can run any exercise on your own.
The basic workflow (memorise this)
- Open the session folder in VS Code (File → Open Folder → Session1, Session5, or Session6).
- Select the .venv interpreter if prompted (bottom-right status bar).
- Open the integrated terminal (Ctrl+` or View → Terminal).
- Confirm the prompt starts with (.venv).
- Type the python command for the exercise and hit Enter.
Pattern 1 — Script with no arguments
The simplest case. You just run it and read the output. Example: Session 5 script 01.
Pattern 2 — Script with a --prompt argument
Most Session 1 text-generation scripts take a --prompt flag. The value is a string — wrap it in double quotes so the shell sends the whole sentence as one argument.
Change the text inside the quotes and run again. Same script, different output. That is the whole point of these exercises — they are little playgrounds.
Pattern 3 — Script with multiple arguments
Some scripts take more than one flag. Vision and comparison exercises are a good example — they want a file path plus a question.
Pattern 4 — Script with subcommands
Session 1 script 10 is a mini CLI with four subcommands: summarize, ask-image, make-poster, speak. Pick one and add its required flags.
Where do output files go?
Scripts that generate images, audio, or data write to an output/ folder inside the session. Look in the VS Code file explorer after the run — new files appear automatically.
- Session 1 H8 image generation → output/generated.png
- Session 1 H9 text-to-speech → output/speech.mp3
- Session 1 H11 story pipeline → output/story_pipeline/scenes.json + audio/ + images/
Debugging a script (when something breaks)
- Click the left margin next to any line to set a breakpoint (red dot).
- In the terminal type: python -m debugpy --listen 5678 --wait-for-client src/01_text_basic.py --prompt "hello" — OR easier, press F5 and choose "Python File".
- Execution pauses at your breakpoint. Inspect variables in the left Debug panel.
- Use F10 to step over, F11 to step into, and F5 to continue.
Running the SAME script with different inputs
In the VS Code terminal press the Up arrow to recall your last command. Edit the text inside the quotes and hit Enter. This is the fastest way to iterate on prompts during the workshop.
# Run 1
python src/01_text_basic.py --prompt "Write a haiku about the sea"
# Press Up arrow, edit the prompt
python src/01_text_basic.py --prompt "Write a haiku about a coffee shop"
# Up arrow again
python src/01_text_basic.py --prompt "Write a limerick about Python"Things that will NOT work (and why)
Cheat sheet — one command per exercise
python src/01_text_basic.py --prompt "..."
python src/02_text_params_lab.py --prompt "..."
python src/03_prompt_roles.py --topic "..."
python src/04_no_memory_demo.py
python src/05_context_memory_demo.py
python src/06_image_analysis_basic.py --image assets/sample1.png --question "..."
python src/07_image_analysis_compare.py --image1 assets/a.png --image2 assets/b.png
python src/08_image_generation.py --prompt "..."
python src/09_text_to_speech.py --text "..."
python src/10_cli_mini_app.py <summarize|ask-image|make-poster|speak> ...
python src/11_story_scene_pipeline.py --storyline "..." --num_scenes 5# All Session 5 scripts run with no arguments — just the file name
python 01_plain_response_basics.py
python 02_json_mode_basics.py
# ... through 20_chat_completions_parse_refusal.py# Same pattern as Session 5, but from the scripts/ folder
python scripts/00a_openai_smoke_test.py
python scripts/01_model_init_and_params.py
# ... through 09_structured_output_json_schema.py