Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68293

Re: Save to a file, but avoid overwriting an existing file

From Emile van Sebille <emile@fenx.com>
Subject Re: Save to a file, but avoid overwriting an existing file
Date 2014-03-12 12:38 -0700
References <lfpjv9$tki$1@news1.carnet.hr>
Newsgroups comp.lang.python
Message-ID <mailman.8099.1394653162.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 3/12/2014 5:29 AM, zoom wrote:

> 2. Alternatively, a unique string could be generated to assure that no
> same file exists. I can see one approach to this is to include date and
> time in the file name. But this seems to me a bit clumsy, and is not
> unique, i.e. it could happen (at least in theory) that two processes
> finish in the same second.

I tend to use this method -- prepending the job name or targeting 
different directories per job precludes duplication.  Unless you're 
running the same job at the same time, in which case tempfile is the way 
to go (which I use for archiving spooled print files which can occur 
simultaneously.)

Emile




Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Save to a file, but avoid overwriting an existing file zoom <zoom@yahoo.com> - 2014-03-12 13:29 +0100
  Re: Save to a file, but avoid overwriting an existing file Skip Montanaro <skip@pobox.com> - 2014-03-12 07:37 -0500
  Re: Save to a file, but avoid overwriting an existing file Tim Chase <python.list@tim.thechases.com> - 2014-03-12 08:33 -0500
  Re:Save to a file, but avoid overwriting an existing file Dave Angel <davea@davea.name> - 2014-03-12 14:22 -0400
  Re: Save to a file, but avoid overwriting an existing file Emile van Sebille <emile@fenx.com> - 2014-03-12 12:38 -0700
  Re: Save to a file, but avoid overwriting an existing file Cameron Simpson <cs@zip.com.au> - 2014-03-13 09:19 +1100
  Re: Save to a file, but avoid overwriting an existing file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-12 23:04 +0000
  Re: Save to a file, but avoid overwriting an existing file Ben Finney <ben+python@benfinney.id.au> - 2014-03-13 11:22 +1100

csiph-web