Question
Which practice avoids a common mistake with Shallow vs Deep Copy?
- Ignore the Shallow vs Deep Copy issue and rely on team discipline instead of clearer APIs or invariants.
- Silence the Shallow vs Deep Copy problem by using broad catches, hidden globals, or extra shared mutable state.
- Do not assume list.copy() or dict.copy() isolates nested mutable members, because inner objects still alias the original.
- Prefer the version of Shallow vs Deep Copy that makes behavior less predictable as long as the code still runs.
Hint
Look for the option that protects correctness instead of hiding the problem.
Answer and rationale
Correct answer: C. Do not assume list.copy() or dict.copy() isolates nested mutable members, because inner objects still alias the original.
Do not assume list.copy() or dict.copy() isolates nested mutable members, because inner objects still alias the original. This is a common failure mode in real Python code and a frequent interview follow-up.
Track: Python