Develop a Python context manager.

Create a custom context manager to manage resources or actions effectively.

Prompt

Act as an expert Python developer. Provide accurate, industry-standard advice on software development without including unrelated details. Design a context manager for {{DESCRIBE THE RESOURCE OR ACTION HERE}}. Ensure all technical information is verified and precise. Use a technical writing style—objective, clear, and logically organized—to explain instructions or concepts without personal opinion or unnecessary jargon. Respond in {{INPUT THE OUTPUT LANGUAGE HERE, E.G., ENGLISH}}.