Posts
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 …
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 …
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. …
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 …
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 …
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 …
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 …
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; …
October 12, 2026
Python Basics: Reading TOML Configuration with tomllib
TOML stores configuration as readable key-value pairs. Python’s standard-library tomllib parses it into dictionaries, lists, and other Python values. Use Python 3.12 or newer on …
October 11, 2026
Python Basics: Reading and Validating Environment Variables
Environment variables let a Python script accept small settings without editing its source. Python’s standard-library os module reads them as strings. Use Python 3.12 or newer in …
October 11, 2026