4 ms·
Python has the idiom he describes as a builtin. with open(filename) as f: ...your func goes here If you want to create your own custom one: @
by yummyfajitas 10y ago
Python has the idiom he describes as a builtin.
with open(filename) as f:
...your func goes here
If you want to create your own custom one:
@contextlib.contextmanager
def with_a_foo(...):
foo = ...
yield foo
...cleanup the foo...
It's less terse (and in my opinion more readable [1]) than J, but same idea.
[1] I very rarely find point free programming to be comprehensible. This may be my mental limitation.