Skip to content
Sharp

Python Internals · interview question

Which naming or modeling choice is strongest for mutability traps?

Multiple choiceMediumchapter-19-curatedpremiumpython-internalsmutability-traps
python
def add_flag(flags: list[str] | None = None) -> list[str]:
    flags = [] if flags is None else flags
    flags.append("seen")
    return flags
Choose one answer
Answer and explanation

Correct answer

C. Use names and structures that describe the business fact directly instead of temporary implementation noise.

Why

Clear naming and modeling shorten debugging, review, and onboarding time.

Test yourself on Python Internals

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

Start free test
All Python Internals questions →