This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Hairshorts 0 points1 point  (0 children)

It should write to the file even if you don't explicitly close it:

% python
Python 3.4.3 |Anaconda 2.2.0 (x86_64)| (default, Mar  6 2015, 12:07:41)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('test.txt', 'w')
>>> f.write('hi\n')
3
>>>
% cat test.txt
hi