Python language

Closure

A function together with the enclosing scope it captured, keeping those variables alive after the outer call returns.

Why interviewers ask about it

Behind decorators, memoisation and the late-binding loop bug where every closure sees the final loop value. The fix is a default argument or functools.partial.

This term is part of the free Python Full-Stack interview preparation module - browse the full glossary for every definition.