3 个仓库
Patterns that prevent hidden shared state by using None as a sentinel and reassigning the mutable value inside the function body.
Distinct from Default Arguments: Distinct from Default Arguments: focuses specifically on the Python anti-pattern of mutable default arguments and the guard pattern to avoid it.
Explore 3 awesome GitHub repositories matching programming languages & runtimes · Mutable Default Argument Guards. Refine with filters or upvote what's useful.
30 Seconds of Python is a curated collection of short, reusable Python code snippets designed for quick reference and immediate reuse. It provides an interactive browser that lets you explore snippets organized by tags, search across names and descriptions, and copy code to your clipboard with a single click. The collection covers a broad range of common programming tasks, including list and dictionary operations, string formatting and manipulation, date and time calculations, and color format conversion. It also includes utilities for data transformation, such as converting between case styl
Provides a code snippet demonstrating how to avoid mutable default arguments in Python functions.
This project is a comprehensive library of practical Python code examples and patterns. It provides a collection of scripts and snippets designed to demonstrate a wide range of programming tasks, from basic syntax to advanced implementation patterns. The repository focuses on several core domains, including the implementation of concurrency and multithreading examples, data analysis snippets for cleaning and manipulating tabular data, and various data visualization examples. It also covers automation scripts for file system management and a variety of general programming patterns. Additional
Implements guards against the mutable default argument anti-pattern by using None as a sentinel.
attrs is a Python library that automatically generates initialization, representation, equality, hashing, and ordering methods from declarative class attribute definitions. At its core, it provides a class decorator metaprogramming framework that intercepts class creation to rewrite the class body, producing dunder methods without manual boilerplate. The library includes a comprehensive attribute validation toolkit with built-in validators for type checks, range constraints, regex matching, length limits, and logical composition of validation rules. The library distinguishes itself through it
Provides per-instance mutable default values via factory functions, avoiding shared-state bugs in data classes.