(test) ? a:b
Ben Finney
ben+python at benfinney.id.au
Sun Oct 26 20:38:13 EDT 2014
Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
> Do you really not see the connection between counting and summing?
Connection? Of course. But I also see a huge distinction. I'm surprised
you could misunderstand my position to the extent you think such a
question needs to be asked.
The difference between “sum these values” versus “count these values” is
important. That's at the root of why I find it confusingly wrong to sum
True or False values.
Do you really not see the distinction between counting and summing?
The question is just as silly that way.
> If you have three apples, and I have two apples, then in total we have
> (count the apples: one two three, four five) five apples.
If you have three apples in one basket, and I have two apples in one
basket, “sum the baskets” is quite a different operation from “count the
baskets”.
[3, 2]
What is the sum of those values?
How many values are there?
The distinction between those is why I find it unhelpful to express “how
many values?” with “sum them”.
> Alas, you missed the bigger bug: I'm counting *blank lines*, not
> non-blank lines. You need a `not` in there.
Which is, shall we say, not incompatible with the position that the
“count the matches by summing bools” method is an unclear expression of
intent :-)
--
\ “Sittin' on the fence, that's a dangerous course / You can even |
`\ catch a bullet from the peace-keeping force” —Dire Straits, |
_o__) _Once Upon A Time In The West_ |
Ben Finney
More information about the Python-list
mailing list