<br><div class="gmail_quote">On Wed, Aug 8, 2012 at 9:59 AM, Oleg Broytman <span dir="ltr"><<a href="mailto:phd@phdru.name" target="_blank">phd@phdru.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On Thu, Aug 09, 2012 at 02:18:53AM +1000, Ben Finney <<a href="mailto:ben%2Bpython@benfinney.id.au">ben+python@benfinney.id.au</a>> wrote:<br>
> What is a compelling use case for checking precisely for True or False?<br>
<br>
</div>   To distinguish False and None for a tri-state variable that can have<br>
3 values - "yes", "no" and "unspecified" - True, False and None in<br>
Python-speak.<br></blockquote><div><br></div><div>I'd probably write that this way:</div><div><br></div><div>    if t is None:</div><div>        # not specified</div><div>    elif t:</div><div>        # true</div><div>

    else:</div><div>        # false</div><div><br></div><div>on the other hand, if I had a variable that could be either a number or True/False, I would probably write:<br><br></div><div>    if t is True:</div><div>        #</div>

<div>    elif t is False:</div><div>        #</div><div>    else:</div><div>        # use t as a number</div><div><br></div><div>just as I would for any other singleton value. Why does the PEP say that == True is preferred to is True?</div>

<div><br></div></div><br clear="all"><font face="arial, helvetica, sans-serif">--- Bruce</font><div><font face="arial, helvetica, sans-serif">Follow me: <a href="http://www.twitter.com/Vroo" target="_blank">http://www.twitter.com/Vroo</a> <a href="http://www.vroospeak.com/" target="_blank">http://www.vroospeak.com</a></font></div>

<div><font face="arial, helvetica, sans-serif"><br></font></div><br class="Apple-interchange-newline">