Posts
Python Basics: Track Line Origins Across Several Files
When combining small reports, keep both the overall row number and the original file location. FileInput streams an explicit file list while exposing those two coordinates. Prepare …
October 28, 2026
Python Basics: Test Scheduled Event Order with a Virtual Clock
A scheduler test does not need real sleeping. Supplying a virtual clock makes deadlines, priorities, and cancellation deterministic while leaving the event queue behavior intact. …
October 28, 2026
Python Basics: Retrieve Source Lines and Refresh Cached Text
Diagnostic tools often need one source line by number. linecache offers one-based lookup, but a cached result needs deliberate refresh when the underlying source changes. Prepare a …
October 28, 2026
Python Basics: Read Compressed Text and Concatenated bzip2 Streams
A bzip2 file can be processed as text, while the byte API can decode concatenated compressed streams. The incremental decoder stops after one stream, which matters when parsing a …
October 28, 2026
Python Basics: Inspect Fixed Byte Ranges with mmap
A binary file can be inspected through a memory mapping without first reading the entire file into a Python bytes object. This example contrasts a read-only mapping with a private …
October 28, 2026
Python Basics: Distinguish Metadata Equality from File Content Equality
Two files can have the same size and modification time yet contain different bytes. A controlled fixture makes the shallow comparison shortcut visible before performing a content …
October 28, 2026
Python Basics: Display Grouped Hex and Incremental CRC Values
Binary diagnostics benefit from readable hex groups and a repeatable checksum. binascii provides both without pretending that a checksum authenticates its input. Prepare a scratch …
October 28, 2026
Python Basics: Decode Quoted-Printable Bytes Before Text
Mail transport encoding and text encoding are separate layers. Decode quoted-printable into bytes first, then interpret those bytes using the declared character set. Prepare a …
October 28, 2026
Python Basics: Check XZ Stream Completion and Trailing Bytes
An XZ payload can be followed by unrelated bytes. The incremental LZMA decoder exposes both stream completion and trailing data, making it possible to reject a payload that is not …
October 28, 2026
Python Basics: Bound Diagnostic Representations with reprlib
A diagnostic line should not dump an entire large collection. Configure representation limits, then protect a custom representation against a self-reference. Prepare a scratch …
October 28, 2026