From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On Behalf Of 
Danny Yoo
Sent: Tuesday, November 11, 2014 5:25 PM
To: Ben Finney; tutor@python.org
Subject: Re: [Tutor] “has a value of True” versus “evaluates true”

 

 

On Tue Nov 11 2014 at 3:09:38 PM Ben Finney <ben+pyt...@benfinney.id.au 
<mailto:ben%2bpyt...@benfinney.id.au> > wrote:

"Clayton Kirkwood" <c...@godblessthe.us> writes:

> So, there is a difference between None and False, is that the issue?

Yes. Those two values are different and not equal; but both evaluate
false in a boolean context.

 

 

Just to note; not all programming languages do it this way.  Python is fairly 
permissive in what it allows to be "truthy".  See: 
https://plus.google.com/+ShriramKrishnamurthi/posts/4qvvKYC1R8Y for a brief 
survey of what many other programming languages do.

 

It can be confusing and bug-prone as heck.

 

For myself, I usually want as restrictive an approach as possible with respect 
to what things are considered "truthy".  If I'm in a boolean context, I will 
explicitly make the expression being tested be either True or False, and that's 
it.  That way, I know I won't get into shaky waters.  I program in multiple 
languages: I don't want to spend brain power remembering yet another a truth 
table about truth.

 

Thanks, Danny, that’s kind of the thing I learned about this whole issue. Force 
the issue truth by casting. Don’t know if I’ll always keep it, but that seems 
prudent. What led to a portion of this whole issue was that I was assuming that 
equal sign assignment would produce a True/False certainty which could be 
tested. I vaguely recall this premise in another language, probably C or Perl.

 

Truthfully,

 

Clayton

 

To quote: "Let your statement be: 'Yes, yes', or "no, no': anything beyond 
these is of evil."

 

:P

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to