<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="color:#000000"><span style="color:rgb(34,34,34)">On Mon, Mar 18, 2019 at 7:04 AM Rhodri James <<a href="mailto:rhodri@kynesim.co.uk">rhodri@kynesim.co.uk</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 18/03/2019 12:19, Richard Damon wrote:<br>
> On 3/18/19 7:27 AM, Greg Ewing wrote:<br>
>> Juancarlo Añez wrote:<br>
>><br>
>>> if settings[MY_KEY] is True:<br>
>>> ...<br>
>><br>
>> If I saw code like this, it would take a really good argument to<br>
>> convince me that it shouldn't be just<br>
>><br>
>> if settings[MY_KEY]:<br>
>> ...<br>
>><br>
> That means something VERY different. The first asks if the item is<br>
> specifically the True value, while the second just asks if the value is<br>
> Truthy, it wold be satisfied also for values like 1.<br>
<br>
Yes. And the latter is what people almost always mean.<br></blockquote><div><br></div><div class="gmail_default" style="color:rgb(0,0,0)">No, it depends heavily on the context. In GUI code, Oleg's example (tri-state checkbox) is a pervasive idiom. There's lots of code that says "if x is True" or "if x is False" or "if x is None" and that's a very clear indicator that you are dealing with these "booleans that can also be 'unset'".</div></div></div>