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. Django Authentication and Permissions

    TL;DR

    Django provides a complete authentication and authorization sub-system out of the box. Use @login_required to restrict views to authenticated users and @permission_required to enforce granular access control based on custom permissions defined in your models.

  2. Enumerate Function

    TL;DR

    The enumerate() function adds automatic counters to any iterable, returning tuples of (index, value) pairs that make loops cleaner and more Pythonic.

  3. Concurrent Futures

    TL;DR

    The concurrent.futures module provides a simple, high-level interface for executing tasks concurrently using either threads or processes, making parallel programming accessible without dealing with low-level threading or multiprocessing details.

  4. Math Module: Mathematical Functions and Constants

    TL;DR

    The math module provides mathematical functions like sin(), cos(), sqrt(), and constants like pi and e for scientific and mathematical computations.

    Interesting!

    The math.isclose() function solves floating-point comparison issues by checking if two numbers are “close enough” rather than exactly equal, essential for robust numerical code.

  5. 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.

  6. 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.