r/Python • • Nov 25 '22

Intermediate Showcase defer in python!

https://github.com/dankeyy/defer.py

stupid but works lol hope you like it

303 Upvotes

62 comments sorted by

View all comments

Show parent comment

4

u/james_pic Nov 25 '22

It is occasionally useful, if you need to close a large or variable number of things in a block of code. Fortunately, contextlib.ExitStack is already in the stdlib and is a less evil way to do this.