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


Groups > comp.lang.python > #74277 > unrolled thread

Re: error handling when opening files

Started byAlex Burke <alexjeffburke@gmail.com>
First post2014-07-09 21:54 +0200
Last post2014-07-09 21:54 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: error handling when opening files Alex Burke <alexjeffburke@gmail.com> - 2014-07-09 21:54 +0200

#74277 — Re: error handling when opening files

FromAlex Burke <alexjeffburke@gmail.com>
Date2014-07-09 21:54 +0200
SubjectRe: error handling when opening files
Message-ID<mailman.11711.1404935699.18130.python-list@python.org>
> If that's what you're expecting, then your message is wrong, because
> you say "file never opened" - but you possibly DID open it, and maybe
> read something from it. The choice between the two forms should be
> based on whether you want to distinguish between errors on opening and
> errors on reading, or conflate them as "file unreadable". There are
> times and places for each style.

Yeah, got you - most of the responses echoed that it comes down to what
the error situations are and whether they genuinely can or cannot be dealt
with in the same way.

In the case where you do want to handle the cases differently (i.e. it was
there but oh my the contents turned out to be garbage) it does make me
wonder how you deals with that without ending up with nested try/catch - but
perhaps that would be time to use functions to make it read better.

Thanks!

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web