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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '(at': 0.04; 'exists.': 0.07; 'subject:file': 0.07; 'string': 0.09; 'archiving': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'second.': 0.09; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'targeting': 0.16; 'tempfile': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'seems': 0.21; 'print': 0.22; 'header:User-Agent:1': 0.23; 'tend': 0.24; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; '(which': 0.31; 'unique,': 0.31; 'file': 0.32; 'running': 0.33; 'could': 0.34; 'but': 0.35; 'i.e.': 0.36; 'method': 0.36; 'two': 0.37; 'to:addr :python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; "you're": 0.61; 'name': 0.63; 'happen': 0.63; 'different': 0.65; 'finish': 0.65; 'occur': 0.65; 'received:12': 0.81; 'subject:Save': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Emile van Sebille <emile@fenx.com>
Subject Re: Save to a file, but avoid overwriting an existing file
Date Wed, 12 Mar 2014 12:38:54 -0700
References <lfpjv9$tki$1@news1.carnet.hr>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 12.184.110.78
User-Agent Mozilla/5.0 (Windows NT 6.2; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
In-Reply-To <lfpjv9$tki$1@news1.carnet.hr>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8099.1394653162.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1394653162 news.xs4all.nl 2956 [2001:888:2000:d::a6]:37019
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68293

Show key headers only | 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