Skip to content
Commitpedia
Log in Join & edit

Python from scratch

Write small Python programs in a clean virtual environment, work with files, debug common errors, add tests and ship an installable command.

Beginner, 8 steps, about 8 hours

  1. Python cheat sheet: strings, lists, dicts and f-strings Learn the core data types first; most Python code is built from these four. Article CMP 0002
  2. Virtual environments with venv Give every project its own environment before you install any package. Article CMP 0001
  3. Fix: ModuleNotFoundError: No module named ‘…’ The most common beginner error; it usually means the wrong environment is active. Article CMP 0007
  4. pathlib cheat sheet: files and folders in Python Read and write files the modern way instead of joining path strings by hand. Article CMP 0003
  5. Fix: TypeError: ‘NoneType’ object is not subscriptable Learn to trace where a None came from; the habit helps with every bug. Article CMP 0008
  6. Logging instead of print Swap print debugging for logging so your programs explain themselves. Article CMP 0004
  7. Testing with pytest: first tests, fixtures and parametrize Write a few small tests now so the capstone project stays easy to change. Article CMP 0006
  8. Build a Python command-line to-do app: from empty folder to installable command Capstone: combine environments, files, logging and tests in one real tool. Article CMP 0261

Start with step 1