Polymorphism and Duck Typing

Scenario: One report should accept servers, queues, and databases that all expose status().

New words, in plain English

Python often relies on behavior: if an object supplies the needed method, use it. Abstract base classes and protocols can formalize larger interfaces, but simple code can stay flexible.

Analogy: A Python program is like a clear set of instructions for a careful helper: names label things, indentation groups steps, and errors explain where the helper became confused.

A small, real example

def report(resource):
    print(resource.status())

for resource in resources:
    report(resource)
Tip: Ask for the smallest behavior a function needs.
Goal: Practice this idea in the py-oop-inheritance challenge at /labs/python. Fix the broken program, run it yourself, then use check to prove the real end state.