Python v2 logo — two snakes, red and blue python™v2
Donate

Documentation

Everything you need to get Python v2 running: on your desktop, in VS Code, in a dev container or Codespaces, or in any code editor you already love. Then the whole language, on one page. New to Python v2? Start the tutorial — 10 runnable lessons.

01 Install — Desktop

Python v2 has no dependencies and no install step. If you have Python 3.10+ and Git, you're done. Works on macOS, Linux, Windows (native or WSL), and a fridge with a shell.

Step 1 — check Python
python3 --version    # need 3.10 or newer
git --version
Step 2 — get the runtime
git clone https://github.com/gefrus112/pythonv2
cd pythonv2
Step 3 — verify it works
python3 -m pyv2 --version
# Python v2 0.2.0

python3 -m pyv2 examples/hello.pyv2
# Hello, World!
# 2 + 2 = 4
Step 4 — run the test suite (optional, 1 second)
python3 -m unittest discover -s tests -t .
# ... OK

Command line

CommandWhat it does
python3 -m pyv2 script.pyv2Run a program
python3 -m pyv2 -c 'print(42)'Run a one-liner
python3 -m pyv2Start the REPL (... continues blocks)
python3 -m pyv2 --versionPrint the version
python3 -m pyv2 --helpShow usage

Windows notes

02 VS Code

The repository ships ready-made VS Code config in .vscode/ and a language extension in editors/vscode/ for syntax highlighting of .pyv2 files.

Quick start (run & debug your code)

  1. Open the pythonv2 folder in VS Code (File → Open Folder…).
  2. Open any .pyv2 file, e.g. examples/fib.pyv2.
  3. Press Ctrl+Shift+B (macOS: Cmd+Shift+B) — the default build task runs python3 -m pyv2 on the current file.
  4. Output appears in the Terminal panel. That's it.

The included .vscode/tasks.json defines two tasks: Run Python v2 file (default build) and Python v2 REPL. The included .vscode/settings.json associates *.pyv2 with the pyv2 language.

Syntax highlighting (the bundled extension)

  1. Copy the extension folder into your VS Code extensions directory:
    # macOS / Linux
    cp -r editors/vscode ~/.vscode/extensions/pyv2-0.1.0
    
    # Windows (PowerShell)
    Copy-Item -Recurse editors/vscode "$env:USERPROFILE\.vscode\extensions\pyv2-0.1.0"
  2. Restart VS Code (or run Developer: Reload Window).
  3. Open any .pyv2 file — keywords, strings, f-strings, numbers and comments are now colored.

Prefer the marketplace workflow? Pack it once with the vsce tool and install the VSIX:

cd editors/vscode
npx @vscode/vsce package        # builds pyv2-0.1.0.vsix
code --install-extension pyv2-0.1.0.vsix

Alternative: Code Runner

If you use the popular Code Runner extension, add this to your user settings.json and press Ctrl+Alt+N to run:

{
  "code-runner.executorMap": {
    "python": "python3 -m pyv2"
  },
  "code-runner.fileDirectoryAsCwd": true
}

03 Dev Containers & GitHub Codespaces

Opening the repo in a dev container (VS Code or Codespaces) gives you a ready environment in seconds — Python preinstalled, tasks wired, tests passing. The config lives in .devcontainer/devcontainer.json (that's the ".dev" part).

VS Code Dev Containers

  1. Install Docker and the Dev Containers extension (ms-vscode-remote.remote-containers).
  2. Open the repo folder, then run Dev Containers: Reopen in Container from the Command Palette (Ctrl+Shift+P).
  3. First boot pulls the Python image; after that everything is instant.
  4. Run python3 -m pyv2 examples/hello.pyv2 — or just hit Ctrl+Shift+B.

GitHub Codespaces

  1. On GitHub, open the repo → Code → Codespaces → Create codespace on main.
  2. VS Code opens in your browser with the dev container already built.
  3. Everything from the desktop guide works identically inside it.

The container runs python3 -m unittest discover -s tests -t . at build time, so you always start from a green suite.

04 Any Other Code Editor

Python v2 is just text plus a CLI. Any editor that can run a shell command can run it. The universal recipe:

Sublime Text

Tools → Build System → New Build System…
{
    "cmd": ["python3", "-m", "pyv2", "$file"],
    "selector": "source.python",
    "working_dir": "$file_path"
}

Vim / Neovim

" in init.vim / .vimrc
autocmd BufNewFile,BufRead *.pyv2 set filetype=python
autocmd FileType python nnoremap <F5> :w<CR>:!
    \python3 -m pyv2 %<CR>

JetBrains (PyCharm, IntelliJ)

  1. Settings → Editor → File Types → add *.pyv2 to the Python type.
  2. Settings → Tools → External Tools → add a tool with program python3, arguments -m pyv2 $FileName$, working directory $FileDir$.
  3. Bind it to a shortcut under Settings → Keymap.

Notepad++

Run → Run… (F5) with:

cmd /c python3 -m pyv2 "$(FULL_CURRENT_PATH)"

05 Language Quick Reference

The full spec (grammar, semantics, error kinds) lives in docs/LANGUAGE.md. Here is the day-to-day core.

Values

TypeExampleNotes
number1, 2.5, 1e-3Whole numbers print without .0
string"hi", f"hi {x}"Indexed s[0], tons of methods
booltrue, false
nilnilAbsence of a value
list[1, 2, 3]Mutable; negative indices work
map{name: "Ada"}Bare keys, dot access, get(k, default)
fnfn add(a, b): … endFirst-class, real closures
rangerange(10)Lazy, from the range builtin

Operators

KindOperators
Arithmetic+ - * / // % **
Comparison== != < <= > >=
Logicand, or, not
Membershipx in list, k in map, s in string
Ternaryok ? "yes" : "no"
Assignment= += -= *= /= %=

Statements

StatementExample
functionfn add(a, b): return a + b end
branchif x: … elif y: … else: … end
whilewhile running: step() end
forfor item in [1, 2, 3]: print(item) end
range loopfor i in range(1, 10, 2): print(i) end
jumpreturn, break, continue

Builtins

FunctionDescription
print(...)Print values, space-separated
len(x)Length of string / list / map / range
range(stop) · range(a, b, step)Integer range
str int float bool reprConversions
abs floor ceil round sqrt powMath
min · maxOver arguments or one list
type(x)"number", "string", "list", "map", …
push pop insert removeList mutation
keys values has getMap access
sort sort_by joinHelpers
assert(cond, msg?)Raises AssertionError when falsy
chr ord clock inputMisc (input is CLI-only)

06 Try It Right Here

No install needed to experiment — this is the real interpreter, running in your browser. Edit and hit Run.