3 ms·
You can do basically the same thing in python @contextlib.contextmanager def open(*args) # file open try: yield file
by asdfaoeu 9y ago
You can do basically the same thing in python
@contextlib.contextmanager
def open(*args)
# file open
try:
yield file
finally:
file.close()
with open(args) as file:
# use file
- RX14 9y agoThat's pretty cool! But as nice as it is, to me it's just syntax sugar over the wrong abstraction instead of something beautiful in it's own right.