Creating a temporary file in Python
Diez B. Roggisch
deets at nospam.web.de
Wed Oct 31 13:16:10 CET 2007
> 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:
> Is there a way to make it work or I have to manually manage
> everything ?
> My non working code:
> f = tempfile.NamedTemporaryFile(suffix='.sql')
> p = subprocess.Popen([SQL_PLUS, '-s', dsn, '@', SQL_PLUS_SCRIPT,
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
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.
More information about the Python-list