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


Groups > comp.lang.python > #38178

Re: LBYL vs EAFP

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Pete Forman <petef4+usenet@gmail.com>
Newsgroups comp.lang.python
Subject Re: LBYL vs EAFP
Date Tue, 05 Feb 2013 09:49:06 +0000
Organization A noiseless patient Spider
Lines 13
Message-ID <867gmnjdkd.fsf@gmail.com> (permalink)
References <5110415c$0$29986$c3e8da3$5496439d@news.astraweb.com> <mailman.1339.1360021575.2939.python-list@python.org> <51109001$0$21856$c3e8da3$76491128@news.astraweb.com> <mailman.1350.1360041622.2939.python-list@python.org> <5110a73a$0$21856$c3e8da3$76491128@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx04.eternal-september.org; posting-host="cdf6132ee4c43c2d1457a368e89c85c9"; logging-data="17152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3Ehhy9VZg6mFuypDSFB+R"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.2 (windows-nt)
Cancel-Lock sha1:BWsCjX1AJ5EOtI3xwudldIumegg= sha1:GWNrEEYeizflTpZ2ee1bq6BhlQE=
Xref csiph.com comp.lang.python:38178

Show key headers only | View raw


Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:
>> I want to check that a value is a number. [...]
> I'm leaning towards an isinstance check

Well that is the answer to your question, whether the value *is* a
number. EAFP can answer the question whether the value *behaves* like a
number, where the criterion depends on what your code is aiming to do
with the value.

BTW what if the value is Not-a-Number? ;-)

-- 
Pete Forman

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


Thread

LBYL vs EAFP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-05 10:16 +1100
  Re: LBYL vs EAFP Chris Angelico <rosuav@gmail.com> - 2013-02-05 10:38 +1100
    Re: LBYL vs EAFP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-05 03:52 +0000
      Re: LBYL vs EAFP Chris Angelico <rosuav@gmail.com> - 2013-02-05 16:19 +1100
  Re: LBYL vs EAFP Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-04 16:46 -0700
    Re: LBYL vs EAFP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-05 04:52 +0000
      Re: LBYL vs EAFP Chris Angelico <rosuav@gmail.com> - 2013-02-05 16:20 +1100
        Re: LBYL vs EAFP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-05 06:31 +0000
          Re: LBYL vs EAFP Pete Forman <petef4+usenet@gmail.com> - 2013-02-05 09:49 +0000
            Re: LBYL vs EAFP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-05 23:04 +1100
              Re: LBYL vs EAFP Chris Angelico <rosuav@gmail.com> - 2013-02-05 23:25 +1100
      Re: LBYL vs EAFP Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-04 22:40 -0700
  Re: LBYL vs EAFP Dave Angel <davea@davea.name> - 2013-02-04 18:55 -0500
  Re: LBYL vs EAFP Chris Angelico <rosuav@gmail.com> - 2013-02-05 11:45 +1100
  Re: LBYL vs EAFP Ethan Furman <ethan@stoneleaf.us> - 2013-02-04 16:26 -0800
  Re: LBYL vs EAFP Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-05 01:00 +0000
  Re: LBYL vs EAFP Terry Reedy <tjreedy@udel.edu> - 2013-02-05 02:53 -0500

csiph-web