Y
Hacker News
new
|
ask
|
show
|
jobs
by
andreareina
1461 days ago
Plain context manager doesn't actually introduce a new scope:
with open("foo") as f: s = f.read() print(f) # closed file object still exists
A macro that looks like a context manager would work but beware the edge cases.