What's the advantage of using with .. as in pyhon?
- by prosseek
with open("hello.txt", "wb") as f:
f.write("Hello Python!\n")
seems to be the same as
f = open("hello.txt", "wb")
f.write("Hello Python!\n")
f.close()
What's the advantage of using open .. as instead of f = ?
Is it just syntactic sugar? Just saving one line of code?