You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f81ffb1
Browse filesBrowse the repository at this point in the historyBrowse files
feat: port to TypeScript/Vite and add plotting surface
Migrate the engine, UI, and tests from vanilla ES modules under
js/ to strict TypeScript under src/, bundled by Vite and tested with
vitest. Removes the old js/ tree, css/app.css, and the scripts/serve.js
static server; adds tsconfig, vite config, lockfile, and a GitHub Pages
deploy workflow.
Adds a Plot surface: scatter(xs, ys, "title") / line(xs, ys, "title")
push a plot spec rendered as SVG on a Plot tab alongside the Memory
canvas, so the object graph and the chart read the same data.
Fixes:
- plot title used the repr form (displayValue) instead of the print
form, so line(..., "trend") titled the chart 'trend'; use printArg
- Tab completion suggested sorted() and list(range(...)), which the
engine does not implement and would raise NameError
Docs:
- rewrite README and DESIGN for the TS/Vite layout, supported subset,
meta-commands, and the Plot surface
- align the ADR 001 title and engine header comments to the
learn-python product name
Co-Authored-By: Claude Code <noreply@anthropic.com>
@@ -110,6 +111,7 @@ Scale: 11 / 12 / 14 / 16 / 20 / 28 / 40. Line length in the brief ≤ 62ch.
110
111
111
112
1.**Reference draw** — assignment draws an amber edge from name → object with stroke-dash animation.
112
113
2.**Alias pulse** — when a shared mutable object changes, every inbound edge pulses once together.
114
+
3.**Data-to-chart** — `scatter`/`line` reads the same heap lists the Memory canvas shows and draws them as SVG on the Plot tab, so the object graph and the chart agree.
113
115
114
116
### Motion
115
117
@@ -126,12 +128,13 @@ Scale: 11 / 12 / 14 / 16 / 20 / 28 / 40. Line length in the brief ≤ 62ch.
Architectural sibling of [learnGitBranching](https://github.com/pcottle/learnGitBranching): a fully client-side simulator with a live canvas, command shell, goal-checked levels, and statement golf. Where LGB makes git's commit DAG visible, learn-python makes Python's stack/heap object graph visible.
7
+
Architectural sibling of [learnGitBranching](https://github.com/pcottle/learnGitBranching): a fully client-side simulator with a live canvas, command shell, goal-checked levels, and statement golf. Where LGB makes git's commit DAG visible, learn-python makes Python's stack/heap object graph visible — and lets you watch it become a chart.
8
8
9
9
## Run
10
10
11
11
Open https://alisadeghiaghili.github.io/learn-python/ in a browser.
12
12
13
-
Locally, open `index.html` via a static server (ES modules need HTTP):
13
+
Locally, use the Vite dev server (TypeScript ES modules need a bundler):
npm run build # type-check (tsc --noEmit) + production build to dist/
25
26
```
26
27
28
+
## Layout
29
+
30
+
Two live surfaces sit side by side:
31
+
32
+
-**Memory** — stack frames on the left, heap objects on the right, amber reference edges between them. This is the core instrument.
33
+
-**Plot** — `scatter(xs, ys)` and `line(xs, ys, "title")` push a plot spec that renders as SVG on this tab. The memory model and the chart read the same data, which is the pedagogical point: a plot is just a list of `(x, y)` pairs.
34
+
35
+
Plus a **console** REPL at the bottom (statement or meta-command) and a **learning guide** panel on the right with the level brief, par, and next hint.
36
+
27
37
## Sandbox
28
38
29
39
Type Python-subset statements. Meta-commands:
30
40
31
41
| Command | Effect |
32
42
|---------|--------|
33
43
|`help`| subset + meta overview |
34
-
|`levels`| list challenge packs |
35
-
|`level <id>`| load a level |
36
-
|`goal`| show the brief |
44
+
|`levels`| list the 24 levels / 6 series |
45
+
|`level <id>`| load a level (e.g. `level first-name`) |
46
+
|`lesson`| open the current level's lesson text |
47
+
|`goal` / `guide`| focus the right-hand guide panel |
The engine is intentionally a **teaching subset**, not CPython. Every state transition is controlled so the visualizer can show what a real interpreter hides.
59
85
60
86
## Levels
61
87
62
-
Four packs — Bindings, Aliasing, Containers, Frames. Each level has a brief (lab-note card), optional hint, a goal predicate/snapshot, and a statement-par for golf.
88
+
Six series — Names & Bindings, Aliasing & Copy, Containers in Memory, Mutation & Methods, Functions & Frames, Plotting & Capstone. Each of the 24 levels has a brief, optional hint, a goal (predicate or target snapshot), a statement-par for golf, and a worked solution.
89
+
90
+
## Tech
91
+
92
+
TypeScript, Vite, Vitest. No backend, no runtime dependency — the "interpreter" is a hand-written subset whose entire memory graph is inspectable in the browser.
0 commit comments