Question
In Python, which comparison about Mutable Default Arguments is accurate?
- There is no practical difference in behavior, performance, or maintainability when Mutable Default Arguments is involved.
- The oldest option related to Mutable Default Arguments is always the right production choice regardless of workload or context.
- An immutable default such as None is usually a safe placeholder, while a mutable default such as [] can leak state across calls.
- Differences around Mutable Default Arguments are mostly cosmetic, so correctness and debugging quality do not really change.
Hint
Focus on the behavior or tradeoff, not just the keyword.
Answer and rationale
Correct answer: C. An immutable default such as None is usually a safe placeholder, while a mutable default such as [] can leak state across calls.
An immutable default such as None is usually a safe placeholder, while a mutable default such as [] can leak state across calls. This is the comparison that usually separates memorization from understanding.
Track: Python