View on GitHub

Best Practices in Python Programming

A practical Python course from the Scientific Software Center at Heidelberg University

Course prerequisites

Please set up the tools below before the course. The exercises use GitHub and Classroom50, so a working command-line setup is important.

If you already use Conda, pyenv, uv, or an IDE-managed Python installation, that is fine. The important part is that the verification commands at the end work.

Required accounts and tools

Recommended, but not required:

Linux

If you do not already have a preferred Python setup, Conda can be a convenient option because it manages both Python installations and isolated environments. Miniconda is a compact Conda installer. This is only a suggestion, not a course requirement.

Use your distribution’s package manager. On Debian or Ubuntu, this is usually:

sudo apt update
sudo apt install python3 python3-venv python3-pip git

Install GitHub CLI using the official instructions for your distribution: https://github.com/cli/cli#installation

After installing gh, continue with Classroom50 setup.

macOS

Option 1: use official installers:

Option 2: use Homebrew:

brew install python git gh

After installing gh, continue with Classroom50 setup.

Windows

If you do not already have a preferred Python setup, Conda can be a convenient option on Windows because it manages both Python installations and isolated environments. Miniconda is a compact Conda installer. This is only a suggestion, not a course requirement; any setup that provides Python 3.11 or newer is fine.

Conda does not replace Git or GitHub CLI, so install those separately using one of the options below.

Option 1: use official installers:

When installing Python, enable the option that adds Python to PATH.

Option 2: use winget in PowerShell:

winget install --id Python.Python.3.14 -e
winget install --id Git.Git -e
winget install --id GitHub.cli -e

If the exact Python package is not available, install any Python version 3.11 or newer from https://www.python.org/downloads/windows/.

After installing gh, continue with Classroom50 setup.

Classroom50 setup

The course assignments use Classroom50 through a GitHub CLI extension.

Install the student extension:

gh extension install foundation50/gh-student

Check that it is available:

gh student --help

Log in for classroom assignments:

gh student login

This starts the GitHub login flow with the permissions needed to accept and submit Classroom50 assignments. The browser-based login is usually the easiest option.

If the extension is already installed, update it with:

gh extension upgrade gh-student

Verify your setup

On Linux or macOS, run:

python3 --version
python3 -m pip --version
git --version
gh --version
gh student --help
gh auth status

On Windows PowerShell, run:

py --version
py -m pip --version
git --version
gh --version
gh student --help
gh auth status

If you use Conda, activate your Conda environment first and use python in place of py for the first two commands.

Expected result:

If python works on your system but python3 does not, that is fine. Use the command that points to Python 3.11 or newer.

Optional: create a test environment

You do not need to create a course environment before arriving. But if you want to check that environment creation works, try this in a temporary folder.

Linux or macOS:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install ruff pytest mypy
python -m pip list
deactivate

Windows PowerShell:

py -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install ruff pytest mypy
python -m pip list
deactivate

If PowerShell blocks activation scripts, either use a different terminal or run the environment’s Python directly:

.venv\Scripts\python -m pip install ruff pytest mypy

Conda users, including Linux and Windows users following the suggestions above, can use an equivalent Conda environment instead:

conda create -n pbp-course python=3.12
conda activate pbp-course
python -m pip install ruff pytest mypy

Editor or IDE

An IDE is not required, but it makes the course smoother. Good options include VS Code, PyCharm, Spyder, or any editor where you are comfortable editing Python files and using a terminal.

For VS Code, install:

The course will also show that linters, formatters, and type checkers can run in the terminal. IDE integration is a convenience layer on top of those same tools.