<html><body bgcolor="#FFFFFF"><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">On 4 jun 2010, at 21:02, ALAN GAULD &lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt; wrote:</span><br>
</div><blockquote type="cite"><div><span class="Apple-style-span" style="color: rgb(148, 0, 14);"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><br></span></span><span>Eek! no I&#39;d just cast to a bool:</span><br>
<span></span><br><span>    flag = bool(someValue or another)</span><br><span></span><br><span>but the if/else form has the Pythonic virtue of explicitness.</span><br><span></span><br></div></blockquote><br><div>Are you arguing that the if/else form is better than simply casting to bool because it is more explicit? You could hardly name the cast implicit, it&#39;s right there in your face. </div>
<div><br></div><div>If anything, I&#39;d say the if/else is a more indirect way of expressing te cast, even more so when you realize bool is called on the expression anyway by the if statement, to determine its truthiness. </div>
<div><br></div><div>Hugo <span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.289062); -webkit-composition-fill-color: rgba(175, 192, 227, 0.222656); -webkit-composition-frame-color: rgba(77, 128, 180, 0.222656); "></span></div>
</body></html>