The definitive universal agent skill distilling Marty Alchin's classic "Pro Python" (Apress), fully modernized for Python 3.10β3.13+. Equips AI coding assistants with deep object model reasoning, advanced OOP patterns, C3 linearization, and declarative framework architecture.
Install this skill instantly into any agentic coding harness (Claude Code, Cursor, Windsurf, Gemini CLI, PicoClaw, Nanobot, Hermes, OpenClaw, OpenHands, Roo Code, Goose, etc.):
# π Universal 1-command install (interactive)
npx skills add psthi/pro-python-skill
# π Install globally across all current and future workspaces
npx skills add psthi/pro-python-skill -g
# π― Install specifically for a target agent (e.g. Claude Code)
npx skills add psthi/pro-python-skill -g --agent claude-code
# π Preview available skills without installing
npx skills add psthi/pro-python-skill --list- Instant Install (
skills.sh) - Executive Overview
- Why This Skill?
- Quickstart for Novices
- Deep Dive for Advanced Developers
- Chapter & Reference Index (12 Chapters)
- Executable Code Examples
- Contributing & License
While most developer AI prompts rely on generic syntax rules, pro-python embeds the foundational mental models and architectural design patterns that separate amateur scripts from professional Python frameworks.
Synthesized from Marty Alchin's Pro Python and bridged with modern Python 3.10β3.13+ language primitives (PEPs 487, 544, 557, 593, 612, 634, 654), this skill provides:
- Deterministic OOP Decisions: When to use Metaclasses vs
__init_subclass__, how MRO resolves in multiple inheritance, and how to write cooperativesuper()chains. - Negative Constraints & Anti-Patterns: "Tells & Smells" rules that stop LLMs from introducing subtle bugs (e.g. keying caches on instances inside decorator closures, bare
except:, or omittingfunctools.wraps). - Declarative Framework Engineering: Architectural runbook for designing ORMs, schema validators, and data pipelines.
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Typical LLM Behavior β Behavior with Pro Python Skill β
βββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Uses fragile `isinstance` β Employs `typing.Protocol` + duck typing for loose coupling β
β Writes monolithic `if/elif` β Uses Structural Pattern Matching (`match / case`) β
β Leaks memory in closures β Implements thread-safe `@functools.cached_property` β
β Breaks cooperative MRO chains β Enforces C3-linearized cooperative `super()` calls β
β Guesses text encodings β Enforces strict `bytes` vs UTF-8 `str` transport discipline β
βββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
npx skills add psthi/pro-python-skill -gOr clone and run the local multi-agent installer:
git clone https://github.com/psthi/pro-python-skill.git
cd pro-python-skill
bash scripts/install.shOnce installed, your agents will automatically reference these frameworks whenever designing Python architectures. You can also query specific chapters or patterns explicitly:
- "Using the pro-python skill, design a plugin system for our data loaders using
__init_subclass__." - "Check our class hierarchy against the C3 MRO linearization rules in ch04."
- "Refactor this decorator using
ParamSpecto preserve type hints as described in ch12."
Python flattens multiple-inheritance graphs using the C3 linearization algorithm. super() does not call the literal immediate parent in source code; it resolves dynamically against the runtime instance's MRO:
class Base:
def action(self):
print("Base.action")
class MixinA(Base):
def action(self):
print("MixinA start")
super().action()
class MixinB(Base):
def action(self):
print("MixinB start")
super().action()
class Combined(MixinA, MixinB):
def action(self):
super().action()
# MRO: Combined -> MixinA -> MixinB -> Base -> object
# Calling Combined().action() correctly chains through both mixins!- Use
__init_subclass__(PEP 487) for zero-metaclass subclass registries without metaclass conflict issues:
class Exporter:
registry = {}
@classmethod
def __init_subclass__(cls, format_name=None, **kwargs):
super().__init_subclass__(**kwargs)
if format_name:
cls.registry[format_name] = cls
class HTMLExporter(Exporter, format_name="html"): pass- Reserve Metaclasses (
type.__new__/__prepare__) for inspecting/altering the class namespace dictionary before class instantiation occurs.
Never lose argument types or autocomplete when wrapping functions:
from functools import wraps
from typing import Callable, ParamSpec, TypeVar
P = ParamSpec("P")
R = TypeVar("R")
def retry(func: Callable[P, R]) -> Callable[P, R]:
@wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
return func(*args, **kwargs)
return wrapperDefine explicit interface contracts decoupled from class inheritance:
from typing import Protocol, runtime_checkable
@runtime_checkable
class Serializer(Protocol):
def serialize(self) -> dict[str, str]: ...| # | Chapter | Key Frameworks |
|---|---|---|
| 1 | ch01: Principles & Philosophy | Zen of Python, Samurai Principle, DRY, Pareto & Robustness Rules |
| 2 | ch02: Advanced Basics | try/except/else/finally, Exception Chaining, Context Managers (with), Generators |
| 3 | ch03: Functions & Decorators | *args/**kwargs, Closures, Optional-Argument Decorator Pattern, Partial Application |
| 4 | ch04: Classes & Metaclasses | Inheritance, C3 Linearization, Cooperative super(), Metaclasses, __prepare__() |
| 5 | ch05: Common Protocols | Operator Overloading, Comparison Protocols (__eq__ + __ne__), Iterables |
| 6 | ch06: Object Management | Identity/Type/Value, Borg Pattern, Reference Counting, GC, Caching Descriptors |
| 7 | ch07: Strings & Encodings | bytes vs str, struct Binary Packing, Unicode Encodings, UTF-8 |
| 8 | ch08: Documentation | Naming discipline, Docstring standards, reStructuredText, Sphinx |
| 9 | ch09: Testing | doctest vs unittest.TestCase, Assertion specificity (assertEqual vs assertTrue) |
| 10 | ch10: Distribution & Packaging | Licensing (MIT/BSD/LGPL/GPL), Packaging history, PyPI standards |
| 11 | ch11: Sheets CSV Framework | Capstone Declarative Framework, Metaclass field registration, Instantiation ordering |
| 12 | ch12: Modern Python Bridge | __init_subclass__, typing.Protocol, @functools.cached_property, ParamSpec, @dataclass(slots=True), match/case, pyproject.toml |
Located in examples/:
examples/01_cooperative_multiple_inheritance.py: Verified C3 MRO resolution demo.examples/02_plugin_registry_init_subclass.py: Zero-metaclass plugin registration.examples/03_type_safe_decorator.py: ModernParamSpectype-preserving wrapper.examples/04_structural_protocol.py: Runtime & static structural protocol verification.
- Skill Wrapper License: Apache-2.0
- Source Attribution: Based on "Pro Python" by Marty Alchin (Apress, 2010), synthesized and modernized for Python 3.10β3.13+ coding agents.
- Framework & Tooling Credit: Structured and generated using the book-to-skill framework by @virgiliojr94.