Creating a temporary file in Python

looping kadeko at
Wed Oct 31 13:48:18 CET 2007

On Oct 31, 2:16 pm, "Diez B. Roggisch" <de... at> 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')
    p = Popen([SQL_PLUS, '-s', dsn,
        '@', SQL_PLUS_SCRIPT,],
        stdout=PIPE, stderr=STDOUT)

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.

More information about the Python-list mailing list