Skip to main content Brad's PyNotes

Posts

2025

  1. String Module

    TL;DR

    The string module provides string constants, Template class for simple substitution, and advanced formatting utilities for text processing.

    Interesting!

    The string.Template class provides a safer alternative to % formatting - it prevents code injection by not allowing arbitrary expressions!

  2. Stdlib Tour 2 Tutorial

    TL;DR

    The second stdlib tour covers professional-grade modules: precise decimal arithmetic, efficient data structures, logging, threading, and binary data handling.

    Interesting!

    The decimal module can represent exact monetary values without floating-point errors - crucial for financial applications where precision matters!

  3. Pickle Module

    TL;DR

    The pickle module serializes Python objects to bytes and deserializes them back - enabling object persistence and inter-process communication.

    Interesting!

    Pickle can serialize almost any Python object, including functions, classes, and nested objects - but never unpickle untrusted data as it can execute arbitrary code!

  4. PEP 622 Pattern Matching

    TL;DR

    PEP 622 introduced match-case statements for structural pattern matching, enabling elegant destructuring and dispatch based on data shape and values.

    Interesting!

    Pattern matching brings functional programming elegance to Python - you can destructure complex nested data in a single line and handle different cases cleanly!

  5. PEP 3107 Function Annotations

    TL;DR

    PEP 3107 introduced syntax for adding metadata to function parameters and return values, stored in __annotations__ - the foundation for modern type hints.

  6. Glob Module: Unix-Style Pathname Pattern Matching

    TL;DR

    The glob module finds all pathnames matching a Unix shell-style pattern using wildcards like * (any characters), ? (single character), and [seq] (character ranges), making file discovery and batch operations simple.

  7. Appetite Tutorial

    TL;DR

    Python excels at automation and rapid development with its simple syntax, powerful features, and “batteries included” philosophy - perfect for getting things done quickly.

  8. Venv Tutorial

    TL;DR

    Virtual environments create isolated Python installations to prevent package conflicts between projects using python -m venv.

    Interesting!

    Virtual environments solve the “dependency hell” problem - you can have different versions of the same library for different projects without conflicts!

  9. Threading Module

    TL;DR

    The threading module enables concurrent execution through threads with synchronization primitives like Lock, Event, and Semaphore for safe resource sharing.

    Interesting!

    Python’s Global Interpreter Lock (GIL) means only one thread executes Python code at once - threading helps with I/O-bound tasks, not CPU-bound ones!

  10. Sqlite3 Module

    TL;DR

    The sqlite3 module provides a lightweight, disk-based database interface that supports SQL queries without requiring a separate server process.

    Interesting!

    SQLite is the most widely deployed database engine in the world - it’s built into every smartphone, browser, and operating system!

  11. PEP 585 Generics

    TL;DR

    PEP 585 made built-in collections generic, allowing list[int] instead of List[int] - eliminating duplicate type hierarchies in the typing module.

    Interesting!

    Before PEP 585, Python had two separate type systems - one for runtime and one for type hints. Now built-in collections work for both!

  12. Heapq Module: Efficient Priority Queue Operations

    TL;DR

    The heapq module provides heap queue (priority queue) operations using a binary heap implemented as a list, where heappush() and heappop() maintain the heap invariant with O(log n) complexity.

  13. Stdlib Tour Tutorial

    TL;DR

    Python’s standard library provides essential modules for OS operations, file handling, math, networking, dates, and performance measurement - “batteries included”!

    Interesting!

    Python’s standard library is so comprehensive that many tasks don’t require external dependencies - from web requests to compression, it’s all built-in!

  14. Statistics Module

    TL;DR

    The statistics module provides mathematical statistics functions for calculating averages, spread measures, and correlations without external dependencies.

    Interesting!

    Unlike floating-point calculations, the statistics module can work with Decimal and Fraction types for exact mathematical precision in statistical calculations!

  15. PEP 492 Async Await

    TL;DR

    PEP 492 introduced async def and await keywords, creating native coroutines that make asynchronous programming cleaner and more intuitive than generator-based approaches.

  16. PEP 380 Yield From

    TL;DR

    PEP 380 introduced yield from syntax for delegating to subgenerators, simplifying generator composition and enabling generators to return values.

    Interesting!

    yield from was the foundation that made async/await possible - it established the delegation pattern that coroutines needed!

  17. Informal Intro Tutorial

    TL;DR

    Python’s interactive interpreter lets you experiment immediately with numbers, strings, and lists using intuitive syntax and meaningful indentation.

    Interesting!

    Python uses indentation instead of braces to define code blocks - making the visual structure of your code match its logical structure!