On 4/12/2013 3:32 AM, Chris Angelico wrote:
On Fri, Apr 12, 2013 at 4:25 PM, Rob Schneider <rmsc...@gmail.com> wrote:

The close method is defined and flushing and closing a file, so

it should not return until that's done.



What command are you using to create the temp file?



re command to write the file:
f=open(fn,'w')
... then create HTML text in a string
f.write(html)
f.close

Hold it one moment... You're not actually calling close. The file's
still open. Is that a copy/paste problem, or is that your actual code?

In Python, a function call ALWAYS has parentheses after it. Evaluating
a function's name like that returns the function (or method) object,
which you then do nothing with. (You could assign it someplace, for
instance, and call it later.) Try adding empty parens:

f.close()

and see if that solves the problem. Alternatively, look into the
'with' statement and the block syntax that it can give to I/O
operations.

I say *definitely* use a 'with' statement. Part of its purpose is to avoid close bugs.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to