Skip to main content Brad's PyNotes

Welcome!

Welcome to Brad’s Python Notes (PyNotes!).

This blog is a collaboration between me, the python documentation and my Claude Code pair-writer/programmer who is helping me with drafting the original outline for each post. After that I can extend, adjust and tweak the posts to build a much more diverse and comprehensive blog than I would otherwise have time or energy to build.

Recent posts

  1. Textwrap Module: Elegant Text Formatting and Wrapping

    TL;DR

    The textwrap module provides functions for formatting text blocks with intelligent line wrapping, indentation control, and paragraph formatting - perfect for creating clean output, documentation, and user interfaces.

  2. PEP 544: Protocols - Structural Subtyping (Static Duck Typing)

    TL;DR

    PEP 544 introduces Protocol classes that enable structural subtyping (static duck typing) - type checking based on what methods an object has rather than its inheritance hierarchy, making Python’s type system more flexible and duck-typing friendly.

  3. Struct Module: Binary Data Processing and C Integration

    TL;DR

    The struct module converts between Python values and C structs represented as bytes objects, enabling binary data processing for network protocols, file formats, and hardware communication with precise control over byte layout.

  4. Tempfile Module: Secure Temporary File Handling

    TL;DR

    The tempfile module creates secure temporary files and directories with automatic cleanup, preventing race conditions and ensuring cross-platform compatibility for safe temporary data handling.

  5. Timeit Module: Precision Performance Measurement

    TL;DR

    The timeit module provides precise execution time measurement for small code snippets, automatically handling timing complexities and providing both programmatic and command-line interfaces for performance benchmarking.

  6. Decimal Module: Precise Decimal Arithmetic

    TL;DR

    The decimal module provides exact decimal arithmetic without floating-point precision errors, essential for financial calculations, scientific computing, and any application requiring precise decimal representation.