Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73465
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| 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; 'subject:not': 0.03; 'handler': 0.05; 'classes.': 0.09; 'clause': 0.09; 'except:': 0.09; 'lawrence': 0.09; 'try:': 0.09; 'unhandled': 0.09; 'python': 0.11; 'exiting': 0.16; 'imo,': 0.16; 'old-style': 0.16; 'sys.exit(1)': 0.16; 'systemexit': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'not,': 0.20; 'example': 0.22; 'case.': 0.24; 'replace': 0.24; 'specify': 0.24; 'sort': 0.25; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'equivalent.': 0.31; 'exceptions': 0.31; 'class': 0.32; 'fri,': 0.33; 'advice': 0.35; 'anywhere': 0.35; 'except': 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'useful': 0.36; 'should': 0.36; 'depends': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'catch': 0.60; 'most': 0.60; 'such': 0.63; 'due': 0.66; 'believe': 0.68; '20,': 0.68; 'bare': 0.84; 'subject:check': 0.84; 'edwards': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=/WeDydOpqi8xtePKvT7Mx4+ZyfMv0mafg8mpxxfkkYk=; b=GaGqjur38nNEmmgY+YriAqQj6GRZfz7fuaheMHeUuvTFI8QNdFcQPztr433Tjebxjk HvhB6uv982LTMsN5YCo6d1+otxUxYJ9PrJBESXkWJcf7kTxzEZe0z6HL9YCWXJ5IXe7U BHVfY/orxfvFarPLXD1z/Q44dc6awCVShKvWZHGHMmVaOE6I0CkOP1xbwF8eCiAIYPzc mxITPQZ2aOg+S5q+xrH99Z055IjoisSwqrppB0gzAXXMTz4jfNhUn9i1YrG3Dz8MJymE 4oGYYBAerOY24iM50h4aGZknw17brerO//4tMppppfCaNyhGIdjCtfYAj9P42NpM2rj3 dInQ== |
| X-Received | by 10.236.200.8 with SMTP id y8mr1762984yhn.137.1403279127350; Fri, 20 Jun 2014 08:45:27 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <lo1gf4$ifp$1@reader1.panix.com> |
| References | <d5ca21d7-23e6-4240-83d8-262d0f877f7e@googlegroups.com> <c21b1d32-a716-4629-aad6-357b62a8f529@googlegroups.com> <1496766103424961606.682559sturla.molden-gmail.com@news.gmane.org> <mailman.11166.1403271661.18130.python-list@python.org> <lo1gf4$ifp$1@reader1.panix.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 20 Jun 2014 09:44:47 -0600 |
| Subject | Re: how to check if a value is a floating point or not |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.11170.1403279135.18130.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1403279135 news.xs4all.nl 2880 [2001:888:2000:d::a6]:56915 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73465 |
Show key headers only | View raw
On Fri, Jun 20, 2014 at 8:28 AM, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2014-06-20, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
>
>> For the OP a very important rule of thumb is never use a bare except, so
>> this is right out.
>>
>> try:
>> doSomething()
>> except:
>> WTF()
>
> IMO, that sort of depends on WTF() does. One case where a bare except
> is well used is when stdandard output/error are not going anywhere
> useful and you want to log the exception and then terminate:
>
> try:
> whatever()
> except Exception as e:
> syslog("foobar: terminating due to unhandled exception %s.\n" % e)
> sys.exit(1)
Logging unhandled exceptions and exiting is the job of sys.excepthook,
so I would prefer to replace it with a custom exception handler in
this case.
Also, this isn't an example of a bare except, which is an except
clause with no exception class specified. "except:" and "except
Exception:" are not equivalent. In Python 3, I believe that "except:"
and "except BaseException:" are equivalent. In Python 2 they are not,
because exceptions are also allowed to be old-style classes. In any
case, the advice against bare excepts stems from the fact that bare
excepts will catch things that you usually should not try to catch,
such as SystemExit and KeyboardInterrupt, and so you should normally
specify "except Exception:" in the most general case.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
how to check if a value is a floating point or not nicholascannon1@gmail.com - 2014-06-18 22:53 -0700
Re: how to check if a value is a floating point or not Gary Herron <gary.herron@islandtraining.com> - 2014-06-18 23:22 -0700
Re: how to check if a value is a floating point or not Nicholas Cannon <nicholascannon1@gmail.com> - 2014-06-18 23:48 -0700
Re: how to check if a value is a floating point or not Ben Finney <ben@benfinney.id.au> - 2014-06-19 17:19 +1000
Re: how to check if a value is a floating point or not Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-19 01:23 -0600
Re: how to check if a value is a floating point or not Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-19 01:37 -0600
Re: how to check if a value is a floating point or not Sturla Molden <sturla.molden@gmail.com> - 2014-06-19 13:46 +0000
Re: how to check if a value is a floating point or not Nicholas Cannon <nicholascannon1@gmail.com> - 2014-06-19 23:14 -0700
Re: how to check if a value is a floating point or not Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-20 00:22 -0600
Re: how to check if a value is a floating point or not Sturla Molden <sturla.molden@gmail.com> - 2014-06-20 13:16 +0000
Re: how to check if a value is a floating point or not Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-20 14:40 +0100
Re: how to check if a value is a floating point or not Grant Edwards <invalid@invalid.invalid> - 2014-06-20 14:28 +0000
Re: how to check if a value is a floating point or not alister <alister.nospam.ware@ntlworld.com> - 2014-06-20 15:15 +0000
Re: how to check if a value is a floating point or not Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-20 09:44 -0600
csiph-web