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


Groups > comp.lang.python > #88843

Re: try..except with empty exceptions

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'root': 0.05; 'tries': 0.07; 'string': 0.09; 'agree,': 0.09; 'escape': 0.09; 'semantic': 0.09; 'python': 0.11; '>the': 0.16; 'advantage.': 0.16; 'codebases.': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'hmm.': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'oppose': 0.16; 'portable': 0.16; 'record,': 0.16; 'simpson': 0.16; 'exception': 0.16; 'fix': 0.17; 'wrote:': 0.18; '(but': 0.19; 'machine': 0.22; 'to:name:python- list@python.org': 0.22; 'header:User-Agent:1': 0.23; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'then.': 0.30; 'work.': 0.31; 'code': 0.31; '(usually': 0.31; 'exceptions': 0.31; 'class': 0.32; 'run': 0.32; 'guess': 0.33; 'could': 0.34; 'subject:with': 0.35; "can't": 0.35; 'common': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; "i'll": 0.36; 'bringing': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'remove': 0.60; 'catch': 0.60; 'truly': 0.60; 'content-disposition:inline': 0.62; 'believe': 0.68; 'bare': 0.84; 'confusing': 0.84; 'everything.': 0.84; 'received:192.168.15': 0.84; 'subject:..': 0.84; 'why?': 0.91
Date Sun, 12 Apr 2015 07:37:34 +1000
From Cameron Simpson <cs@zip.com.au>
To "python-list@python.org" <python-list@python.org>
Subject Re: try..except with empty exceptions
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <CAPTjJmpBUct=UXMLdSpBTL8uH56qsMc6AZxg5SC7D=zt7Tqsig@mail.gmail.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <CAPTjJmpBUct=UXMLdSpBTL8uH56qsMc6AZxg5SC7D=zt7Tqsig@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20
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.234.1428788263.12925.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1428788263 news.xs4all.nl 2945 [2001:888:2000:d::a6]:50642
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88843

Show key headers only | View raw


On 11Apr2015 21:21, Chris Angelico <rosuav@gmail.com> wrote:
>But I agree, it would be very nice if Python 3 could have abolished
>the truly confusing part of this, where "except:" catches everything.
>Forcing people to spell it "except BaseException:" would fix all of
>this. How hard is it to deprecate and then remove that, same as string
>exceptions were removed?

I guess I'll go over there to oppose it then.

Why? It makes it harder to write portable python 2/3 code and does not add any 
semantic advantage.

Unless there's a common root exception class in Python 2, which I believe there 
isn't, you can't catch all exceptions in python 2 without the "except:" syntax.  
Which means the _only_ way to have some code in both 2 and 3 that does it 
requires 2 codebases.

As one who tries to have his code run in both 2 (usually recent 2, like 
2.6/2.7) and 3, this change would cause a signification breakage for me without 
bringing any semantic benefits.

Without vigorous use of the time machine I don't see a fix here.

For the record, I would be ok (but not "for") never having had bare "except" if 
all exceptions had always had a common root.

Hmm. Can I catch "object"? Sounds awful, but might work.

Cheers,
Cameron Simpson <cs@zip.com.au>

EMACS: Escape Meta Alt Control Shift

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


Thread

Re: try..except with empty exceptions Cameron Simpson <cs@zip.com.au> - 2015-04-12 07:37 +1000
  Re: try..except with empty exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-12 14:05 +1000

csiph-web