Re: Creating a temporary file in Python
- From: looping <kadeko@xxxxxxxxx>
- Date: Wed, 31 Oct 2007 08:34:16 -0700
On Oct 31, 2:16 pm, Sion Arrowsmith <si...@xxxxxxxxxxxxxxxxxxxxxx>
wrote:
" [ ... ] 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)."
I didn't notice this limitation when reading the doc, thanks to point
me to it.
So for the future newbie that look something like this, here is my
final code:
fd, filename = tempfile.mkstemp(suffix='.sql')
f = os.fdopen(fd, 'wb')
try:
f.write(txt.encode('cp1252'))
f.close()
p = Popen([SQL_PLUS, '-s', dsn,
'@', SQL_PLUS_SCRIPT, filename],
stdout=PIPE, stderr=STDOUT)
p.wait()
finally:
os.remove(filename)
.
- References:
- Creating a temporary file in Python
- From: looping
- Re: Creating a temporary file in Python
- From: Sion Arrowsmith
- Creating a temporary file in Python
- Prev by Date: Re: shouldn't 'string'.find('ugh') return 0, not -1 ?
- Next by Date: Re: why did these companies choose Tcl over Python
- Previous by thread: Re: Creating a temporary file in Python
- Next by thread: py2exe (or other exe builder) on Vista system for Vista/XP install targets.
- Index(es):
Relevant Pages
|