Python — From Basics to Advanced · Advanced Typing
Protocol — Duck Typing with Types
Advanced Typing
Introduction
Protocol (PEP 544) brings structural typing — a class "fits" if it has the right methods/attributes, no inheritance required. Duck typing verified statically. Perfect for loose coupling, tests with fakes, and dependency injection.