python-gotchas

Identify and explain common Python programming pitfalls with corrected code examples.

51|10|Updated Oct 22, 2025
One-click install
npx skills add https://github.com/JosiahSiegel/claude-plugin-marketplace --skill python-gotchas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-gotchas
Source: https://github.com/JosiahSiegel/claude-plugin-marketplace/tree/main/plugins/python-master/skills/python-gotchas
Command: npx skills add https://github.com/JosiahSiegel/claude-plugin-marketplace --skill python-gotchas

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers avoid and understand common, subtle pitfalls in Python that lead to unexpected behavior and bugs.

Core Features & Use Cases

  • Identify Pitfalls: Explains common issues like mutable default arguments, scope problems, and iteration errors.
  • Provide Solutions: Offers clear code examples and fixes for each identified gotcha.
  • Use Case: When debugging a function that behaves strangely with default parameters, consult this Skill to quickly identify and fix the mutable default argument issue.

Quick Start

Explain the gotcha of mutable default arguments in Python and provide a corrected code example.

Frequently Asked Questions about python-gotchas

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Python function behave strangely with default parameters?

Your Python function likely suffers from mutable default arguments, a common gotcha where default values are evaluated only once at function definition. This Skill identifies the issue and provides corrected code examples using None to ensure robust, predictable behavior.

How do Python scope rules affect variable resolution in nested functions?

Python scope rules follow the LEGB order—Local, Enclosing, Global, and Built-in—to resolve variable names. This Skill explains how this mechanism works and provides solutions to prevent scope-related bugs in your programming.

What is the best way to fix late binding issues in Python closures?

The best way to fix late binding in Python closures is to bind the current variable value using a default argument in the inner function. This Skill explains this subtle language behavior and provides corrected code examples for robust programming.

Why does dictionary mutation during iteration cause a runtime error in Python?

Dictionary mutation during iteration causes a runtime error because Python prevents modifying a dictionary's structure while traversing it. This Skill identifies this iteration pitfall and provides solutions like iterating over a copied list of items to ensure safe debugging.

How do I identify common Python gotchas for better code quality?

You identify common Python gotchas by learning subtle language behaviors like mutable default arguments, LEGB scope rules, and late binding in closures. This Skill highlights these programming pitfalls and provides solutions to ensure predictable, high-quality code.