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


Groups > comp.lang.python > #73461

Re: how to check if a value is a floating point or not

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail
From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: how to check if a value is a floating point or not
Date Fri, 20 Jun 2014 14:28:52 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 36
Message-ID <lo1gf4$ifp$1@reader1.panix.com> (permalink)
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>
NNTP-Posting-Host dsl.comtrol.com
X-Trace reader1.panix.com 1403274532 18937 64.122.56.22 (20 Jun 2014 14:28:52 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Fri, 20 Jun 2014 14:28:52 +0000 (UTC)
User-Agent slrn/1.0.1 (Linux)
Xref csiph.com comp.lang.python:73461

Show key headers only | View raw


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)    

Alternatively, if you're not at the top level in the call tree,
sometimes it's useful to log an exception but still pass it on up in
case somebody higher up wants to handle it:

def asdf():
    try:
        whatever()
    except Exception as e:
        syslog("Function asdf() terminating due to exception %s.\n" % e)
        raise    
        
-- 
Grant Edwards               grant.b.edwards        Yow! ... or were you
                                  at               driving the PONTIAC that
                              gmail.com            HONKED at me in MIAMI last
                                                   Tuesday?

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


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