Re:Statically-typed error handling in Python using Mypy
by staticassertion on Monday December 09, 2019 @11:49PM
(#21749683)
Escaping multiple times would be unnecessary with a type based system, by definition.
Sure, no one should need to do that anymore, it's just an example. There are many other cases that are similar, however.
`using` is a language construct, not something that is part of an interface. It also does not prevent close from being called twice.
As for closing resources, you can use a pattern such as using(open("file.txt"), (f) => { ... }) if your language doesn't already support such a construct.