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


Groups > comp.lang.python > #68315

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!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.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'subject:file': 0.07; 'messing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simpson': 0.16; 'header:User- Agent:1': 0.23; 'simpler': 0.24; 'header:X-Complaints-To:1': 0.27; 'said,': 0.30; 'values.': 0.31; 'writes:': 0.31; 'url:python': 0.33; 'but': 0.35; 'received:com.au': 0.36; 'url:org': 0.36; 'ben': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'heard': 0.39; 'realize': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; '8bit%:29': 0.60; 'catch': 0.60; 'url:3': 0.61; 'believe': 0.68; 'therefore': 0.72; 'received:125': 0.84; 'subject:Save': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Save to a file, but avoid overwriting an existing file
Date Thu, 13 Mar 2014 11:22:55 +1100
References <lfpjv9$tki$1@news1.carnet.hr> <20140312221925.GA67514@cskk.homeip.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host vmx15867.hosting24.com.au
X-Public-Key-ID 0xBD41714B
X-Public-Key-Fingerprint 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:j+EslyQ1i8hJurJgZsLeYpwjWOw=
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.8115.1394670188.18130.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1394670188 news.xs4all.nl 2924 [2001:888:2000:d::a6]:59871
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68315

Show key headers only | View raw


Cameron Simpson <cs@zip.com.au> writes:

> Therefore you need to continue _only_ if you get EEXIST. Otherwise
> abort.

If you target Python 3.3 or later, you can catch “FileExistsError”
<URL:http://docs.python.org/3/library/exceptions.html#FileExistsError>
which is far simpler than messing around with ‘errno’ values.

-- 
 \     “I know you believe you understood what you think I said, but I |
  `\         am not sure you realize that what you heard is not what I |
_o__)                                     meant.” —Robert J. McCloskey |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious 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