Skip to main content

πŸ§ͺ Playground

Loading Python (15 MB, one-time)…

Run Python in your browser

Full CPython via Pyodide. Write, run, share. Code lives in the URL β€” copy the link and the recipient sees your exact snippet.

NEW✨ Refactor Coach β€” paste any Python, get a senior review β†’
✎ playground.py
$ output

Bringing up CPython in your browser…

β—‹Fetching Pyodide WebAssembly (β‰ˆ 4 MB)
β—‹Loading the CPython interpreter
β—‹Mounting the standard library
β—‹Ready β€” clean Python 3.12 shell

Tip: while Python warms up, try editing the code on the left.

Examples

🐚 Try REPL β†’Browse all β†’
β†—
πŸ‘‹Hello, World!

Confirm Python is running. Smallest possible example.

basics
β†—
🐍List comprehensions

The one-liner that makes Python feel like Python.

basicsidioms
β†—
πŸ“Špandas in 12 lines

Load, filter, group, aggregate. No CSV download needed.

pandasdata
β†—
πŸ“ˆPlot with matplotlib

Headless matplotlib via Pyodide β€” figure renders inline in the output panel.

matplotlibnumpyviz
β†—
πŸ“Linear regression with numpy

Fit a line to noisy data in 5 lines.

numpymath
β†—
🌐Call a real HTTP API

Fetch GitHub's API with requests. Auto-installed via micropip.

requestsapi
β†—
⚑asyncio in action

Run three coroutines concurrently with asyncio.gather.

asyncioconcurrency
β†—
πŸ“¦Dataclasses + descriptors

Real validation without writing __init__ by hand.

dataclassesoop
β†—
πŸ”ŽRegex extraction

Pull structured data out of messy text.

regexstrings
β†—
πŸ“„CSV read + write

Pure-stdlib CSV with DictReader / DictWriter. No pandas needed.

csvstdlibfiles
β†—
πŸ“‹JSON parse + serialise

json.loads, json.dumps, custom default for dataclasses.

jsonstdlib
β†—
πŸ”„Generators + lazy eval

Memory-friendly streaming with yield and generator expressions.

generatorsidiomsmemory
β†—
πŸ› Custom context managers

with-statement support via class + via @contextmanager decorator.

context-manageridioms
β†—
⚠Exception patterns

Custom exception hierarchy, EAFP, exception chaining.

exceptionsidioms
β†—
🏷Modern type hints

PEP 604 union types, TypedDict, Protocol β€” what mypy expects in 2026.

typingmypy
β†—
πŸ”itertools tricks

groupby, accumulate, pairwise, combinations β€” the lazy toolkit.

itertoolsstdlibidioms
β†—
πŸŽ€Decorators β€” log + cache + retry

Real-world decorator patterns: logging wrapper, functools.cache, retry on failure.

decoratorsidioms
β†—
πŸ—„SQLite from stdlib

Real database (in-memory) β€” no install. Create, insert, query, parameterise.

sqlitestdlibdatabase
β†—
🧡f-string mini-cookbook

Padding, alignment, thousand separators, dates, debug syntax.

fstringstringsidioms
β†—
πŸ—‚dict patterns

Default values, dict comprehensions, dict union (|), nested gets.

dictstdlib
β†—
🧹pandas β€” clean a messy CSV

Real cleaning: parse dates, strip whitespace, fill missing, dedupe.

pandasdatacleaning
β†—
πŸ–Όnumpy β€” toy blur kernel

Convolve a 1-D signal with a moving-average kernel.

numpymath
β†—
πŸͺ„regex β€” find + replace

Capture groups in re.sub callbacks. Slugify a string.

regexstrings
β†—
🧱OOP β€” properties + validation

@property + @setter pattern for invariant-protected attributes.

oopproperties
cta_title
cta_body

Tips

  • Cmd/Ctrl + Enter runs your code.
  • Pyodide includes pandas, numpy, scipy, matplotlib β€” `import` them directly.
  • Share button puts your code in the URL β€” paste anywhere after a free signup.
  • Code persists in your browser between visits.
  • Non-stock packages (requests, httpx, pydantic, attrs) auto-install via micropip on the first run.