Python has a library called sorcery that allows the implementation of per-scope finalizers similar to Go's defer statement. This library utilizes AST rewriting and live compilation techniques to achieve the desired behavior without the need for decorators or excessive indentation.
















