Skip to content

Posts

Python Basics: Taking the Next Item with heapq

A queue of jobs often needs the most urgent item next. Python’s heapq module maintains a heap in a list, with the smallest item at index zero. Use Python 3.12 or newer on Linux. …

Read more →

October 12, 2026

Python Basics: Summarizing Measurements with statistics

A few summary numbers can make a small set of measurements easier to inspect. Python’s standard-library statistics module handles common averages and measures of spread. Use Python …

Read more →

October 12, 2026

Python Basics: Searching Sorted Lists with bisect

Python’s bisect module finds where a value belongs in an already sorted list. It helps locate duplicate ranges and insert new records without sorting everything again. Use Python …

Read more →

October 12, 2026

Python Basics: Reusing Results with functools

A script may repeat the same calculation many times. A small cache can reuse earlier results. Python’s standard-library functools module provides lru_cache() for this job. Use …

Read more →

October 12, 2026

Python Basics: Giving Choices Names with enum

A job status has a small set of allowed choices. An enumeration gives each choice a name and value, so code can use Status.READY consistently. Use Python 3.12 or newer on Linux. …

Read more →

October 12, 2026

Python Basics: Matching Text with re

Small scripts often need to extract a number, check a label, or tidy spaces. Python’s standard-library re module handles patterns in text. Use Python 3.12 or newer in Bash on …

Read more →

October 12, 2026

Python Basics: Keeping Related Values in a Dataclass

A task has several related values: a name, a retry limit, and labels. A dataclass gives those values named fields without writing a constructor yourself. Use Python 3.12 or newer …

Read more →

October 12, 2026

Python Basics: Formatting Plain Text with textwrap

Readable help messages and short previews make command-line scripts easier to use. Python’s standard-library textwrap module provides a few useful formatting tools. Use Python 3.12 …

Read more →

October 12, 2026

Python Basics: Controlling Decimal Arithmetic and Rounding

Binary floating-point values cannot represent every decimal fraction exactly. Python’s standard-library decimal module lets you work from decimal strings and choose precision and …

Read more →

October 12, 2026

Python Basics: Combining and Batching Iterators

Python’s itertools module helps process values a little at a time. Try combining groups, taking a slice, and splitting work into small batches. Use Python 3.12 or newer on Linux; …

Read more →

October 12, 2026