Y
Hacker News
new
|
ask
|
show
|
jobs
by
codefisher
4147 days ago
The equivalent code with out the context manager is actually this:
f = open('foo.txt') try: contents = f.read() finally: f.close()
So yes, extra reason to prefer the context manager.