IndexCheat SheetServalSource

Python

Can I use…

Feature Python version
f-strings 3.6
walrus operator aka := 3.8
Type Hinting Generics in Standard Collections aka list[str] 3.9 1
Type union operator aka int | float 3.10

Debugging

pyinstrument

pip install pyinstrument
import pyinstrument

with pyinstrument.profile():
    ...

@pyinstrument.profile()
def f():
    ...

https://pyinstrument.readthedocs.io/en/latest/guide.html#profile-a-specific-chunk-of-code

line_profiler

pip install line_profiler
import line_profiler

line_profiler.profile.enable()  # or set the environment variable LINE_PROFILE=1

@line_profiler.profile
def f():
    ...

# cat profile_output.txt

https://github.com/pyutils/line_profiler?tab=readme-ov-file#quick-start-modern

PyTorch

torch.cuda.set_sync_debug_mode(0)

Editing

Visual Studio Code
black
isort
prospector
Universal Ctags

Dependency management

pyenv
Poetry
Unofficial Windows Binaries for Python Extension Packages

Testing

pytest
pytest-randomly
pytest-snapshot
pytest-cov

Debugging

pudb
Add export PYTHONBREAKPOINT="pudb.set_trace" to your ~/.bashrc
pyinstrument
memory-profiler

Backend

Django
huey
jsonschema
environ-config

Frontend

Bootstrap
Mithril

Ops

Caddy
docker-compose
If you can ssh foobar then you can:
DOCKER_HOST=ssh://foobar docker-compose up -d
Note: you may need to bump MaxSessions in your server's /etc/ssh/sshd_config.
Hetzner

Tools

Crontab.guru
RetroTool

Bookmarks

Built-in Functions
Built-in Types
HTTP response status codes
  1. Python 3.8 provides from __future__ import annotations