Skip to main content Brad's PyNotes

Posts

2025

  1. Built-in Functions: Python's Essential Toolkit

    TL;DR

    Python’s built-in functions like map(), filter(), zip(), and enumerate() provide powerful, memory-efficient ways to process data without explicit loops.

    Interesting!

    The any() and all() functions can short-circuit evaluation - any() returns True as soon as it finds one truthy value, making them incredibly efficient for large datasets.

  2. Classes: Object-Oriented Programming in Python

    TL;DR

    Python classes bundle data and functionality together, supporting inheritance, method overriding, and special methods for creating powerful, reusable object-oriented code.

    Interesting!

    Python’s “everything is an object” philosophy means even classes are objects - you can inspect class attributes, pass classes as arguments, and create classes dynamically at runtime.

  3. JSON Module: Data Interchange Made Simple

    TL;DR

    The json module provides simple methods for converting between Python objects and JSON strings using loads() to parse JSON and dumps() to create JSON, essential for web APIs and data storage.

  4. Itertools Module: Iterator Building Blocks for Efficient Loops

    TL;DR

    The itertools module provides memory-efficient iterator building blocks like chain(), combinations(), cycle(), and count() for creating powerful iteration patterns.

    Interesting!

    The itertools.product() function can generate Cartesian products infinitely - perfect for nested loops without the nesting complexity.

  5. PEP 572: The Walrus Operator - Assignment Expressions in Python

    TL;DR

    PEP 572 introduced the walrus operator (:=) in Python 3.8, allowing assignment within expressions to reduce code duplication and improve readability.

    Interesting!

    The walrus operator gets its name from its resemblance to a walrus face - the colon represents the eyes and the equals sign represents the tusks!

  6. PEP 8: The Python Style Guide That Rules Them All

    TL;DR

    PEP 8 defines Python’s official coding style guide, emphasizing readability with 4-space indentation, descriptive naming conventions, and the principle that “code is read much more often than it is written.”