Skip to content
Sharp

Python Internals · interview question

A bug appears around closures and scope. What is the strongest first debugging move?

Multiple choiceMediumchapter-19-curatedpremiumpython-internalsclosures-and-scope
python
def build_multiplier(factor: int):
    def apply(value: int) -> int:
        return value * factor
    return apply
Choose one answer
Answer and explanation

Correct answer

A. Trace one concrete example, inspect the state transitions, and compare them to the intended rule before rewriting anything.

Why

That approach is reliable because it creates evidence. If name binding and outer scope rules feel fuzzy, callback and decorator code becomes harder to debug.

Test yourself on Python Internals

A free test with instant, explained results. No account needed.

Start free test
All Python Internals questions →