Understanding Python default arguments and mutable state
This is an easy Python language-knowledge question that tests whether you understand how default arguments are evaluated and stored in Python. It's a common source of subtle bugs in production code, and interviewers ask it to confirm you know the difference between compile-time and runtime argument binding.
The question requires you to trace through code execution and predict output, paying close attention to when default values are created and how they persist across function calls. This matters in practice because mutable default arguments (like lists or dictionaries) can lead to unexpected shared state between invocations—a pitfall that catches many engineers off guard.
- Default argument evaluation timing
- Mutability and object identity in Python
- Function scope and module-level binding