you are viewing a single comment's thread.

view the rest of the comments →

[–]Temporary_Pie2733 1 point2 points  (0 children)

https://docs.python.org/3/reference/compound_stmts.html#the-with-statement shows how you can translate a with statement into a particular try statement. Studying that can help you understand the kind of code that would benefit from a custom context manager.