Showing content from http://mail.python.org/pipermail/python-dev/attachments/20180320/bb82b4bd/attachment.html below:
<div dir="ltr">No, the whole point of __index__ is that it refuses *all* floats -- otherwise people will do approximate computations that for their simple test inputs give whole numbers, use them as sequence indices, and then find their code broken only when the computation incurs some floating point approximation. OTOH, is_integer() specifically asks whether a given real value is a whole number so you can cast it to int() without rounding, etc.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 20, 2018 at 5:32 PM, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>It seems .as_integer_ratio() has been resolved.<br><br></div>what about the original .is_integer() request? (Or did I miss that somehow?)<br><br></div>Anyway, it seems like __index__() should play a role here somehow... isn't that how you ask an object for the integer version of itself?<br><br></div><div>Could float et al. add an __index__ method that would return a ValueError if the value was not an integer?<br><br></div><div>Of course, as pointed out earlier in this thread, an "exact" integer is probably not what you want with a float anyway....<br><br></div><div>-CHB<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Mar 13, 2018 at 10:29 PM, Tim Peters <span dir="ltr"><<a href="mailto:tim.peters@gmail.com" target="_blank">tim.peters@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">[Tim]<br>
<span>>> An obvious way to extend it is for Fraction() to look for a special<br>
>> method too, say "_as_integer_ratio()".<br>
<br>
</span>[Greg Ewing]<br>
> Why not __as_integer_ratio__?<br>
<br>
Because. at this point, that would be beating a dead horse ;-)<br>
</span><div class="m_-6636410304992068735HOEnZb"><div class="m_-6636410304992068735h5"><span class="">______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br></span>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/chris.<wbr>barker%40noaa.gov</a><span class="HOEnZb"><font color="#888888"><br>
</font></span></div></div></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="m_-6636410304992068735gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R Â Â Â Â Â Â <a href="tel:(206)%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a>Â Â voice<br>7600 Sand Point Way NE Â Â <a href="tel:(206)%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a>Â Â fax<br>Seattle, WA Â 98115 Â Â Â Â <a href="tel:(206)%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a>Â Â main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4