Re: Creating a temporary file in Python
- From: Sion Arrowsmith <siona@xxxxxxxxxxxxxxxxxxxxxx>
- Date: 31 Oct 2007 13:16:38 +0000 (GMT)
looping <kadeko@xxxxxxxxx> wrote:
I want to create a temporary file, read it in an external command and
finally delete it (in Windows XP).
I try to use tempfile module but it doesn't work, the file couldn't be
open by my other process (error like: SP2-0310: unable to open file "c:
\docume~1\looping\locals~1\temp\tmpau81-s.sql")
You're using NamedTemporaryFile. The tempfile documentation
(http://docs.python.org/lib/module-tempfile.html) says:
" [ ... ] Whether the name can be used to open the file a second time,
while the named temporary file is still open, varies across platforms
(it can be so used on Unix; it cannot on Windows NT or later)."
You probably want to use tempfile.mkstemp and explicitly close
(before running the external command) and delete it.
--
\S -- siona@xxxxxxxxxxxxxxxxxxxxxx -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
.
- Follow-Ups:
- Re: Creating a temporary file in Python
- From: looping
- Re: Creating a temporary file in Python
- References:
- Creating a temporary file in Python
- From: looping
- Creating a temporary file in Python
- Prev by Date: Re: A Python 3000 Question
- Next by Date: Re: Creating a temporary file in Python
- Previous by thread: Re: Creating a temporary file in Python
- Next by thread: Re: Creating a temporary file in Python
- Index(es):
Relevant Pages
|