Why this matters
Named functions are reusable, testable, and easier to log/profile.
Prefer named def functions for non-trivial logic; keep lambdas only for tiny, inline expressions.
Named functions are reusable, testable, and easier to log/profile.
Side-by-side examples engineers can pattern-match during review.
key = lambda x: complex_parse(x, cfg, limit=3)def parse_key(x: str) -> int:
return complex_parse(x, cfg, limit=3)
key = parse_keymap(lambda x: heavy(x), xs)def heavy_key(x): return heavy(x); map(heavy_key, xs)From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.