Created
October 23, 2015 17:11
-
-
Save binki/61d739ecd2b158049f62 to your computer and use it in GitHub Desktop.
no need for closing(open()) for with
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> f = open('c:\\users\\ohnob\\appdata\\local\\temp\\f.txt', 'w') | |
>>> with f as fi: | |
... fi.write('hi') | |
... | |
2 | |
>>> f.write('there') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
ValueError: I/O operation on closed file. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment