Cited, real implementations to study (or point an agent at) when designing or reviewing strategy-shaped code.
sorted(key=...)/list.sort. The key function is an interchangeable ordering algorithm passed as an argument — the pattern with zero ceremony.functools.cmp_to_keyadapts old-style comparator strategies into key strategies. docs.python.org/3/howto/sorting.htmllogging.Formatter. A formatting strategy injected into handlers; swapping output formats is constructing a different formatter, not subclassing the handler. docs.python.org/3/library/logging.html#formatter-objects
- requests custom authentication. Anything callable can be passed as
auth=;AuthBasesubclasses are strategy objects attached per-request — the "strategy carries state" case done right. requests.readthedocs.io/en/latest/user/advanced/#custom-authentication - Django password hashers.
PASSWORD_HASHERSis a configured, ordered family of hashing algorithms; verification tries them by preference and upgrades stored hashes — a registry of strategies plus a selection policy. docs.djangoproject.com/en/stable/topics/auth/passwords/ - Fluent Python's strategy→function refactor (Ramalho). The canonical written account of the class-hierarchy-to-functions collapse; this unit's promotions example descends from it.
None of these define a Strategy interface with one method — the signature
is the interface. And each pairs the family with an explicit selection
policy (first match, best score, configured order): when reviewing
strategy code, find where selection happens and check it is deliberate and
tested, not an accident of iteration order.