On Tue, 2008-04-29 at 15:34 +0200, Giovanni Bajo wrote:
> > As of 2.6, Greg's use case is addressed by the new 'delete' parameter on 
> > tempfile.NamedTemporaryFile.
> 
> Then I personally don't have any objection to the removal of os.mkstemp.

os.mkstemp is still useful when you *don't* need the file object, but
the actual file descriptor, for passing to C code or to the child
processes, or to mmap.mmap and such.  It is also familiar to the Unix/C
hackers, and it should cost very little to keep it around.

> Since we're at it, a common pattern I use is to create temporary file to 
> atomically replace files: I create a named temporary file in the same 
> directory of the file I want to replace; write data into it; close it; 
> and move it (POSIX "move": rename with silent overwrite) to the 
> destination file. AFAIK, this is allows an atomic file replacemente on 
> most filesystems.
> 
> I believe this is a common useful pattern that could be handled in 
> module tmpfile (especially since the final "rename" step requires a 
> little care to be truly multiplatform).

I agree, having a tempfile class with rename-on-close semantics would be
very useful.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to