Python Reference

Python scripting patterns for infrastructure automation.

Fundamentals

Topic Description

Basics

Variables, types, control flow, comprehensions

Lists

Creation, slicing, comprehensions, sorting

Dicts

Access patterns, comprehensions, merging

Functions

Args, kwargs, closures, lambdas

Classes

OOP, inheritance, dataclasses, protocols

Typing

Type hints, generics, TypeVar, mypy

Decorators

Function wrappers, class decorators, functools

Files & I/O

Topic Description

Files

File I/O, JSON/YAML parsing, path operations

pathlib

Object-oriented filesystem paths

CLI

Argument parsing with argparse and click

Web & API

Topic Description

FastAPI

Routes, models, dependency injection, middleware

Pydantic

Data validation, fields, validators, serialization

httpx

Async HTTP client, connection pooling, HTTP/2

Requests

HTTP requests and API interactions

Testing & Packaging

Topic Description

pytest

Fixtures, parametrize, mocking, coverage

Packaging

pyproject.toml, setuptools, wheels, publishing

Virtual Envs

venv, uv, pip, dependency management

Async

Topic Description

Async

asyncio, coroutines, tasks, event loops

Scripts

Script Description

system-dashboard.py

12-panel system health PNG — matplotlib, subprocess, Catppuccin Mocha

hardware-dashboard.py

12-panel hardware telemetry — CPU thermals, GPU, battery, WiFi, USB, kernel modules

security-dashboard.py

18-panel unified security — attack surface, 802.1X EAP-TLS, LUKS, AppArmor, kernel hardening, sandboxing, posture score

system-inventory.py

Full system inventory — pandas DataFrames, CSV/JSON export