<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 12, 2018 at 10:07 PM, David Mertz <span dir="ltr"><<a href="mailto:mertz@gnosis.cx" target="_blank">mertz@gnosis.cx</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I'm not sure I'm convinced by Sylvain that Boolean needs to be an ABC in the standard library; Guido expresses skepticism.  Of course it is possible to define it in some other library that actually needs to use `isinstance(x, Boolean)` as Sylvain demonstraits in his post.  I'm not sure I'm unconvinced either, I can see a certain value to saying a given value is "fully round-trippable to bool" (as is np.bool_).</div></blockquote><div><br></div><div>But is an ABC the way to do it? Personally, I'm skeptical that ABCs are a solution to, well, anything (as apposed to duck typing and EAFTP). Take Nick's example:</div><div><br></div><div><span style="font-size:12.8px">"""</span></div><div><span style="font-size:12.8px">The other comparison that comes to mind would be the distinction</span><br style="font-size:12.8px"><span style="font-size:12.8px">between "__int__" ("can be coerced to an integer, but may lose</span><br style="font-size:12.8px"><span style="font-size:12.8px">information in the process") and "__index__" ("can be losslessly</span><br style="font-size:12.8px"><span style="font-size:12.8px">converted to and from a builtin integer").</span><br></div><div>""" </div><div><br></div><div>I suppose we could have had an Index ABC -- but that seems painful to me.</div><div><br></div><div>so maybe we could use a __true_bool__ special method? </div><div><br></div><div>(and an operator.true_bool() function ???)</div><div><br></div><div>(this all makes me wish that python bools were more pure -- but way to late for that!)</div><div><br></div><div>I guess it comes down to whether you want to:</div><div><br></div><div> - Ask the question: "is this object a boolean?"</div><div><br></div><div>or</div><div><br></div><div> - Make this object a boolean</div><div><br></div><div>__index__ (and operator.index())  is essentially the later -- you want to make an index out of whatever object you have, if you can do so.</div><div><br></div><div>-CHB</div><div><br></div><div><br></div><div><br></div></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>