Skip to content
Sharp

Advanced Python · interview question

Which move is the best default when class-based context managers becomes part of this workflow?

Multiple choiceMediumchapter-14-curatedpremiumadvanced-pythonclass-based-context-managers
Choose one answer
Answer and explanation

Correct answer

D. Use context managers when a block of work must clearly acquire and release a resource or scope.

Why

Use context managers when a block of work must clearly acquire and release a resource or scope. That is the stronger engineering move because candidates who talk about ownership boundaries sound grounded in real maintenance work. Manual open/close behavior scattered across the codebase is easier to forget and harder to review.

Test yourself on Advanced Python

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

Start free test
All Advanced Python questions →