[Edu-sig] Truth values and comparisons
Arthur
ajsiegel at optonline.net
Mon Nov 6 14:49:03 CET 2006
Scott David Daniels wrote:
>>Though I guess we are all allowed to define "sound programming" for
>>ourselves.
>>
>>
>
>With the exception you pointed out about space shuttles.
>
>
if sum(abs(the_array)) != 0:
go ahead
Am I still blowing up anything, potentially??
Still preferring something along these lines in the context in which I
am working.
"any" may be more readable (it is certainly more succinct).to the
knowing reader, but less so to the less knowing.
But it is hard to separate readability from some concept of who your
readers might be, and overall context.
It also allows me to switch easily to the concept of "zero for practical
purposes" as opposed to true/false.
if sum(abs(the_array)) > EPS:
go ahead
OTOH, I am the one always fighting condescension.
I can see it be argued (my own objection to some of the arguments
against int/int = int, always , was something along these lines) that
my approach - in a pedagogical settings - effectively avoids an
opportunity to elucidate something that should be elucidated.
Probably no way to win in any black and white sense with these kinds of
issues.
Think I'll go with "any" in the end, unless there is a real reason to
believe that "zero for practical purposes" is or might come into play.
Art
More information about the Edu-sig
mailing list