Skip to content
Sharp

Advanced Python · interview question

Which naming or modeling choice is strongest for class-based context managers?

Multiple choiceMediumchapter-14-curatedpremiumadvanced-pythonclass-based-context-managers
python
class ConnectionManager:
    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc, tb):
        print("closing")
Choose one answer
Answer and explanation

Correct answer

D. 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 Advanced Python

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

Start free test
All Advanced Python questions →