You can write Python in any text editor — Notepad, TextEdit, even nano in the terminal. But a good editor saves you hours of debugging by catching errors as you type, autocompleting code, and reformatting messy lines.
We’ll use Visual Studio Code (VS Code) — a free editor from Microsoft that has the best Python support of any general-purpose editor.
If you prefer PyCharm, Cursor, Zed, or Neovim, that’s perfectly fine. They all support Python well. Stick with what you already know.
Install VS Code
Download VS Code from code.visualstudio.com and install it like any other application.
Open your project folder
Launch VS Code, then choose File → Open Folder… and select the python-fundamentals folder you created in the last lesson. You should see hello.py in the file tree on the left.
Install the extensions
VS Code becomes a Python editor through extensions. Open the Extensions view (the icon that looks like four squares on the left sidebar, or press Cmd+Shift+X on macOS, Ctrl+Shift+X on Windows/Linux) and install these:
- Python (by Microsoft) — the core extension. Adds syntax highlighting, the run button, and the test integration.
- Pylance (by Microsoft) — usually installed automatically with Python. Provides fast autocompletion, hover docs, and basic type checking.
- Ruff (by Astral) — linting and formatting. We’ll cover this properly in the next lesson.
- Even Better TOML — for editing
pyproject.tomlfiles, the modern config format for Python projects.
After installing, restart VS Code so all extensions load cleanly.
Tell VS Code which Python to use
VS Code needs to know which Python interpreter to use. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux) to open the Command Palette, then type:
Python: Select Interpreter
Choose the option that says “uv” or shows a path inside ~/.local/share/uv/python/ (or similar). If you don’t see one yet, that’s fine — we’ll create a virtual environment in lesson 8 of this section and you can pick the interpreter then.
Turn on format-on-save
Open VS Code settings (Cmd+, on macOS, Ctrl+, on Windows/Linux) and search for format on save. Tick the box.
Now every time you save a Python file, Ruff will reformat it. No more arguing about spaces, indentation, or quote style — it just happens.
Turn on strict type checking
Search the settings for python type checking. Set Python › Analysis: Type Checking Mode to strict.
This makes Pylance flag any function that isn’t fully typed, any variable whose type can’t be inferred, and any operation that doesn’t match the declared types. It will feel strict at first — that’s the point. The compiler-like feedback will keep you out of trouble.
Try it out
Open hello.py and add a deliberately broken function:
def add(a: int, b: int) -> int:
return a + "two"
Save the file. Pylance should immediately underline "two" and tell you:
Operator "+" not supported for types "int" and "Literal['two']"
This is the kind of feedback a type checker gives you. We haven’t even run the program yet.
Fix it:
def add(a: int, b: int) -> int:
return a + b
The underline disappears.
A note on keyboard shortcuts
A few VS Code shortcuts worth learning early:
Cmd+P/Ctrl+P— quickly open a file by nameCmd+Shift+P/Ctrl+Shift+P— the Command Palette (every command lives here)Cmd+//Ctrl+/— toggle a comment on the current lineF12— jump to where a function or variable is definedShift+F12— find everywhere a function or variable is used
You don’t need to memorise these. They become muscle memory after a few weeks.
What’s next
Your editor is set up and catching mistakes for you. Next we’ll add Ruff, the linter and formatter that keeps your code consistent.