[plug] Quick Python question
Craig Ringer
craig at postnewspapers.com.au
Fri Jul 2 20:49:17 WST 2004
On Fri, 2004-07-02 at 12:21, Bernd Felsche wrote:
> I want to save the standard input into a scratch file in Python.
> Will
[snip]
> in 2.3 do the trick? For arbitrary input content?
It looks fine to me.
However, 'tempfile' module provides the functions:
TempFile
and
NamedTempFile
which might be worth thinking about. I'd use TempFile over mkstemp if I
knew I wouldn't need to access the temp file from something I couldn't
pass a file descriptor to.
You also have the options of using StringIO, which is useful for when
when you want file-like behaviour but don't need a real on-disk file.
It's nice when you know the input won't be too large, as you don't need
to think about an on-disk file to clean up and keep secure.
--
Craig Ringer
More information about the plug
mailing list