MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/z4aic2/defer_in_python/ixqowkd/?context=3
r/Python • u/dankey26 • Nov 25 '22
https://github.com/dankeyy/defer.py
stupid but works lol hope you like it
62 comments sorted by
View all comments
Show parent comment
4
Couldn’t you just write in the close statement and then just write the “stuff you want to do with f” between the open and close statements?
Or am I missing something?
12 u/relvae Nov 25 '22 If an exception is thrown then close wouldn't be called in that case. Python already has context managers to deal with that but OP has gone rogue lol 1 u/kezmicdust Nov 25 '22 I see! Thanks. 2 u/antiproton Nov 25 '22 It's just a different way to solve similar problems. Similar to putting the close in a try...except...finally
12
If an exception is thrown then close wouldn't be called in that case. Python already has context managers to deal with that but OP has gone rogue lol
1 u/kezmicdust Nov 25 '22 I see! Thanks.
1
I see! Thanks.
2
It's just a different way to solve similar problems. Similar to putting the close in a try...except...finally
View all comments
Show parent comment
4
u/kezmicdust Nov 25 '22
Couldn’t you just write in the close statement and then just write the “stuff you want to do with f” between the open and close statements?
Or am I missing something?