Lesson 1 of 59Your Python toolbox
Python Editors
Set up VS Code or PyCharm for real Python work, debug with breakpoints, run tests from the editor, and use Jupyter for exploring data.
This course assumes you know the Python language from the Python course and basic SQL from the SQL & Databases course. It starts with the tools you will use every day, then builds a real backend with FastAPI. You will spend more hours inside your editor than inside any framework. A well-set-up editor finds your bugs as you type, jumps to the definition of any function in a library, renames a variable across forty files safely, and pauses a live request so you can look at every variable. A badly set-up one underlines every import in red because it is looking at the wrong Python. This lesson covers the two editors most Python teams use, VS Code and PyCharm, plus Jupyter notebooks for exploration, and the habits that make you fast in any of them.
What an editor actually does for Python
Under the friendly window, a Python editor is coordinating a few separate pieces. Knowing them makes almost every setup problem easy to fix.
The editor shows files and sends what you type to the tools behind it.
The single most common setup bug is the editor pointing at the system Python instead of your project's .venv. Your code runs fine with uv run, but the editor shows Import "fastapi" could not be resolved. The fix is always the same: select the interpreter inside .venv.
uv run fastapi dev works, but VS Code underlines import sqlalchemy as unresolved. What is the most likely cause?VS Code
VS Code is a free, general editor that becomes a Python IDE through extensions. Install the Python extension from Microsoft; it brings Pylance (the analyzer) and the Python Debugger with it. Add the Ruff extension for linting and formatting, and the Jupyter extension if you work with notebooks.
Selecting the interpreter. Open the Command Palette (Ctrl+Shift+P, or Cmd+Shift+P on macOS) and run Python: Select Interpreter. VS Code usually finds .venv in the project folder on its own and suggests it. The chosen interpreter shows in the status bar, and new terminals inside VS Code activate it automatically. If you created .venv after opening the folder, run the command again.
A small workspace settings file makes the setup the same for everyone who opens the repo:
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "standard",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
}
}typeCheckingMode controls how strict Pylance is (off, basic, standard, strict). Many teams commit this file so a new hire gets a working editor on the first clone.
Debugging. Click in the gutter left of a line number (or press F9) to set a breakpoint, then press F5. When execution reaches that line, the program pauses and you can see every local variable, hover over expressions, and type Python into the Debug Console to inspect live objects. To debug a FastAPI app, add a launch configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "API",
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"args": ["app.main:app", "--port", "8000"],
"justMyCode": true
}
]
}Now set a breakpoint inside a route, start API, and send a request from the browser or curl. The request pauses mid-flight at your line. Leave out --reload while debugging: the reloader runs your app in a child process, which makes breakpoints unreliable. justMyCode stops the debugger from stepping into library code; turn it off when you need to follow a bug into FastAPI or SQLAlchemy.
The test explorer. With pytest enabled, the beaker icon in the sidebar lists every test. You can run or debug one test with a click, and failed tests show the assertion inline next to the code. Debugging a single failing test is often the fastest way to understand it.
The debugger controls
Every debugger, in any editor, has the same handful of moves. Learn them once.
Match each debugger action to what it does.
Python also has a built-in way to stop: put breakpoint() on a line and run the program in a terminal. You land in pdb, the text debugger, where n steps over, s steps into, c continues, p name prints a value, and q quits. It works over SSH and inside containers where no editor is attached.
How does a debugger pause your code at all? CPython lets a tool register a function that is called on every event: a function call, each new line, a return. Debuggers build on hooks like this one. Here is a tiny tracer that prints what a debugger would see:
Press Run (⌘ Enter) to see what happens.A real debugger does the same thing, but instead of printing it checks "is there a breakpoint on this line?" and, if so, waits for you to click a button. That is also why code runs slower under a debugger.
In the tracer output above, what does the last line say?
total([10.0, 5.5], 0.1) # subtotal = 15.5, cut = 1.55
PyCharm
PyCharm, from JetBrains, is a full IDE built only for Python. Everything works out of the box: no extensions to choose, deep code understanding, and refactorings that are hard to beat. It has a free tier for core Python work and a paid Professional tier that adds framework support (Django, FastAPI, Flask), database tools and remote interpreters; JetBrains has recently merged both into one download, so check the current offer.
- Interpreter. PyCharm detects
pyproject.tomland.venvand offers to use them. You can also set it under Settings, then Project, then Python Interpreter, where uv-managed environments are supported directly. - Run configurations. Every run (a script, a pytest file, a FastAPI app) is a named configuration with its own working directory, environment variables and arguments. Save them to the project so the team shares them. Each has a Run button and a Debug button.
- Refactoring. Rename (
Shift+F6) updates every reference, including imports and string mentions if you ask. Extract method, change signature, and move class are reliable enough to use on large codebases. - Database tools (Professional). Connect to your local Postgres, browse tables, run SQL with completion against the real schema, and view query plans without leaving the editor.
- Search Everywhere. Press
Shifttwice to find any file, class, setting or action by name.
Jupyter notebooks
A notebook (.ipynb) is a document of cells. Each code cell runs in a long-lived Python process called the kernel, and its output (a table, a chart, an error) is saved right below it. That makes notebooks excellent for exploring data, checking what an API returns, or trying a query before it goes into code.
VS Code and PyCharm both open notebooks directly. To use your project's packages, install the kernel package as a dev dependency and pick .venv as the kernel:
uv add --dev ipykernelIn VS Code you can also write # %% on a line in a normal .py file. Each section becomes a runnable cell in the Interactive window, but the file stays plain Python that diffs well in git and can be linted.
Notebooks have one trap that bites everyone: hidden state. The kernel remembers every variable from every cell you have run, in whatever order you ran them. Delete a cell and its variables still exist. A notebook that "works" may fail when someone runs it top to bottom. Before you trust or share a notebook, use Restart Kernel and Run All.
df = load()), then delete it, then run cell 4 (print(df.shape)). What happens?Keep notebooks for exploration. Once code matters, move it into a module with tests, and import it from the notebook if you still want to explore.
Habits that make you fast
The tool matters less than how you drive it. These habits pay off in any editor:
- Use the command palette instead of hunting through menus. You only need to remember roughly what the action is called.
- Navigate by symbol, not by scrolling. Go to definition (
F12in VS Code), find all references (Shift+F12), and go back to where you were. Reading library source this way is how you learn what FastAPI really does. - Rename with the tool (
F2in VS Code,Shift+F6in PyCharm), never with find and replace. The tool understands scope; text search does not. - Accept quick fixes for missing imports and simple lint errors (
Ctrl+.orCmd+.in VS Code,Alt+Enterin PyCharm). - Format on save so you never think about whitespace again.
- Debug instead of adding print statements when the bug is not obvious in thirty seconds.
Choosing
There is no wrong answer, and many teams mix both.
| VS Code | PyCharm | |
|---|---|---|
| Cost | Free | Free core, paid Professional tier |
| Setup | Pick extensions | Works out of the box |
| Strength | Light, fast, one editor for Python, TypeScript, Docker and YAML | Deepest Python analysis and refactoring, built-in database tools |
| Common in | Full-stack teams, notebooks, remote and container work | Large Python codebases, Django shops |
If you also write a frontend, VS Code keeps everything in one place. If you live in a big Python codebase all day, PyCharm's refactoring and inspections are worth trying. Whichever you pick, learn its debugger well.
How this course is laid out
- Your Python toolbox and How backends work: your editor, uv, Ruff and the debugger, then what a backend is and your first FastAPI app with Pydantic models.
- Building a real API and Data and storage: CRUD design, dependencies, settings, errors and auth, then Postgres, SQLAlchemy, migrations, Redis and concurrency bugs.
- Async and background work and API design in depth: the event loop, task queues and WebSockets, then versioning, pagination, error formats, idempotency and OpenAPI.
- Identity and access and Product features: sessions, OAuth, permissions and tenants, then uploads, email, rate limits, feature flags and scheduled jobs.
- Libraries every Python developer knows and Other frameworks: httpx, Typer, NumPy, pandas and scraping, then Django, DRF and Flask, and how to choose between them.
- Testing and Production: tests against real databases, then project structure, observability, security, scaling, CI/CD and deployment.
By the end you can build, test and ship a production FastAPI service. The course closes with a wrap-up that ties it all together.
- interpreter (in an editor)
- The Python executable the editor uses for analysis, running and debugging. It should be the project's
.venv. - Pylance
- The Python language server in VS Code: completion, go to definition and type checking.
- breakpoint
- A marker on a line where the debugger pauses the program so you can inspect its state.
- pdb
- Python's built-in text debugger, entered with
breakpoint(). - run configuration
- A saved recipe for running or debugging: target, arguments, working directory and environment.
- kernel
- The long-lived Python process behind a notebook that runs cells and keeps their variables.