Re: Creating a temporary file in Python
- From: looping <kadeko@xxxxxxxxx>
- Date: Wed, 31 Oct 2007 05:48:18 -0700
On Oct 31, 2:16 pm, "Diez B. Roggisch" <de...@xxxxxxxxxxxxx> wrote:
I'm not an expert, but I think you need to close the file first - you under
windows here, which can be picky about such stuff AFAIK. Or maybe there is
some other mode-specifier.
Diez
Actually closing the file delete it without any chance to use it...
Well I changed my code this way:
filename = tempfile.mktemp(suffix='.sql')
f = open(filename, 'wb')
try:
f.write(txt.encode('cp1252'))
f.close()
p = Popen([SQL_PLUS, '-s', dsn,
'@', SQL_PLUS_SCRIPT, f.name],
stdout=PIPE, stderr=STDOUT)
p.wait()
finally:
os.remove(filename)
I understand the security issues of temporary file (as explained in
Python doc) but maybe standard lib need a NamedTemporaryFile that
could be used by another process.
.
- Follow-Ups:
- Re: Creating a temporary file in Python
- From: Diez B. Roggisch
- Re: Creating a temporary file in Python
- References:
- Creating a temporary file in Python
- From: looping
- Re: Creating a temporary file in Python
- From: Diez B. Roggisch
- Creating a temporary file in Python
- Prev by Date: Re: A Python 3000 Question
- Next by Date: Re: A Python 3000 Question
- Previous by thread: Re: Creating a temporary file in Python
- Next by thread: Re: Creating a temporary file in Python
- Index(es):
Relevant Pages
|
|