LBYL vs EAFP
Pete Forman
petef4+usenet at gmail.com
Tue Feb 5 04:49:06 EST 2013
Steven D'Aprano <steve+comp.lang.python at 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
More information about the Python-list
mailing list