On Mon, Jul 12, 2010 at 6:18 PM, Steven D'Aprano
<st...@remove-this-cybersource.com.au> wrote:
>> I prefere to explicitly write what I want to test:
>>
>> if myInt <> 0:
>
> I would argue against that. Why do you, the coder, care about the
> specific details of treating ints in a boolean context? The int type
> itself knows, leave the decision to it.

I think you're missing the point.  He's not using ints in a boolean
context.  If it were a boolean context, he would be using bools in the
first place.  What he is objecting to is the practice of testing for
special cases of ints (i.e. 0) by treating them as bools.  The
specific details of converting ints to bools are very much relevant
here; as long as 0 is false, it works.  If -1 is false (a semantic I
have actually seen used), then it does not.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to