3 ms·
> can you really imagine yourself writing this all the time Honestly, no. But not because of any measures of beauty, but because I just don't do callbacks all
by falcolas 9y ago
> can you really imagine yourself writing this all the time
Honestly, no. But not because of any measures of beauty, but because I just don't do callbacks all that often.
try:
f = open("foo.txt")
print(f)
print("I am a teapot")
finally:
try: f.close()
except: pass
is what I would be more likely to write (and did write, before context managers were a thing), if the "with" statement didn't exist. It's ugly as sin, but I can put it in front of anybody and they will understand what's going on. I can also tell at a glance that it is correct.