JJoeven

Curriculum

Python

Simple Python from zero: names, lists, functions, files, JSON, errors, tests, and the loop every agent uses.

  1. 01

    Why Python for Agents

    What Python is, why agents are built in it, how print and comments work, and how to run code on this site from zero.

    18 min
  2. 02

    Variables and Names

    Assignment gives a value a name. Learn naming rules, snake_case, rebinding, and the names every agent loop uses.

    18 min
  3. 03

    Types: Numbers, Text, True/False, and None

    Every value has a type. Learn int, float, str, bool, and None, how to convert, and why bool('False') is True.

    18 min
  4. 04

    Compare and Combine Values

    Use ==, !=, <, in, is, and, or, not. Know same value versus same object, short-circuit, and beginner traps.

    18 min
  5. 05

    Strings (Text)

    Make, slice, and clean text with concat, split, join, strip, and replace — the work of prompts and tool names.

    20 min
  6. 06

    Numbers and Math

    Integers, floats, division, rounding, remainders, and how agents count steps, tokens, and cost without lying.

    18 min
  7. 07

    True, False, and None

    Truth tests, empty values, None vs 0 vs empty text, and why if result can lie when result is 0 or a blank string.

    18 min
  8. 08

    Lists

    A list is a row of values you can change. Index, slice, append, pop, and keep an agent's step memory without losing order.

    18 min
  9. 09

    Index and Slice

    Count from 0. A slice is a piece of a list or a string. Off-by-one errors break chunks of text and log windows.

    18 min
  10. 10

    Tuples and Sets

    A tuple is a pair you should not change. A set holds unique names, like allowed tools. Empty set is set(), not {}.

    17 min
  11. 11

    Dictionaries

    A dict maps a key to a value. Learn [], .get, in, items, nested args, and why this is how JSON and tool calls look.

    20 min
  12. 12

    Nested Data (Traces)

    Walk traces as dicts of lists of dicts. Change one field. Chain .get so missing keys do not crash an agent loop.

    21 min
  13. 13

    If, Elif, and Else

    Branch with if, elif, and else. Return early. Guard unknown tools, empty text, and errors before the happy path.

    20 min
  14. 14

    Match and Case

    match picks the first shape that fits. Route a tool dict with case. Keep if for simple yes/no tests.

    20 min
  15. 15

    Loops and Budgets

    for and while repeat work. enumerate, zip, break, continue, any/all, and a hard step budget so the loop cannot run forever.

    20 min
  16. 16

    Functions

    Define a function with def, return a value, write a docstring, pass keyword arguments, and store tools in a dict.

    20 min
  17. 17

    Scope, Defaults, and Extra Arguments

    Local vs global names, default arguments, *args and **kwargs, and why a list default leaks agent memory.

    19 min
  18. 18

    Unpacking

    Split a pair into names, peel the rest of a list, merge dicts with **, and unpack a tool result without losing defaults.

    20 min
  19. 19

    Modules

    Import a file of code, rename it with as, pull one name with from, and only run a main block when this file is the program.

    18 min
  20. 20

    JSON and Text

    Round-trip Python data with dumps and loads. Know what JSON allows, fake a file with a string, and split a CSV line.

    21 min
  21. 21

    with, Files, and Paths

    with always closes. pathlib Path names a file. utf-8 turns text into bytes. This is how read and write tools work.

    19 min
  22. 22

    Errors and try/except

    Catch specific errors, clean up with finally, and turn tool failures into dicts the agent loop can read.

    21 min
  23. 23

    Copy vs Change in Place

    Lists and dicts change in place. Copy when you must not share. Never give two agents one transcript list.

    20 min
  24. 24

    Comprehensions

    Build lists, dicts, and sets in one expression. Filter a trace of dicts. Use a for-loop when the body is more than one step.

    20 min
  25. 25

    Classes

    Make a class with __init__, self, and methods. Build a tiny Agent with goal, step, and run. Know when a function is enough.

    21 min
  26. 26

    Dataclasses

    Use dataclass to hold data. Freeze a ToolCall snapshot. Set list defaults with field(default_factory=list). Compare with a plain dict.

    20 min
  27. 27

    Type Hints

    Write list[str], dict[str, int], and X | None. Hints help you and your editor. They do not stop bad JSON at runtime.

    20 min
  28. 28

    Useful Standard Library

    Use datetime, Counter, defaultdict, islice, sha256, uuid, and copy. Know that time.sleep blocks the whole program.

    20 min
  29. 29

    Regular Expressions

    Use re.search, findall, and groups. Pull a URL or a small blob from messy model text. Prefer json.loads when you already have JSON.

    19 min
  30. 30

    Logging and Secrets

    Log with a list of dicts and levels. Read env vars with os.environ.get. Never print API keys. Redact them with ***.

    18 min
  31. 31

    Virtual Envs and pip

    A virtual env is a private folder of packages. Learn pip, pinned requirements.txt, and why Joeven’s browser has no pip.

    17 min
  32. 32

    HTTP and APIs

    You ask a server, it answers. Learn methods, status codes, JSON bodies, headers, and timeouts — with fake functions, no network.

    20 min
  33. 33

    Parse JSON from a Model

    Models wrap JSON in markdown fences and chat. Strip the fence, parse with json.loads, return an error dict, and never eval().

    20 min
  34. 34

    Retries and Timeouts

    Retry timeouts and 429. Do not retry 400 or 401. Cap tries, print backoff waits, and open a circuit after too many fails.

    19 min
  35. 35

    Async in Simple Words

    Async means wait for many tools at once. Simulate concurrent jobs with a queue and an in-flight limit. Skip event-loop internals.

    18 min
  36. 36

    Tests

    Use assert to test a tool, goal_satisfied, and parse_action. lambda is a tiny check. A runner counts pass and fail.

    19 min
  37. 37

    A Mini Agent in Python

    Put it together: a TOOLS dict, JSON parse, a budgeted loop, a transcript, a finish tool, a fake model, and a printed trace.

    22 min
Start this track