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(\"Hell
The former still closes f if an exception occurs during the f.write().
f
f.write()