A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/027008.html below:

[Python-Dev] Floats as indexes

[Python-Dev] Floats as indexesAahz aahz@pythoncraft.com
Sun, 28 Jul 2002 23:17:24 -0400
On Sun, Jul 28, 2002, Guido van Rossum wrote:
>
> >>> "%d" % 3.14
> '3'
> >>> a = []
> >>> a.insert(0.9, 42)
> >>> a
> [42]
> >>> 
> 
> I find the second example more aggravating than the first.  This
> touches upon a recent discussion, where one of the suggestions was
> to use __index__ rather than __int__ in this case.  I think that's
> not the right solution; perhaps instead, floats and float-like types
> should support __truncate__ and __round__ to convert them to ints in
> certain ways.  (Of course then we can argue about whether to round to
> even, and what to do if the float is so large that its smallest unit
> of precision is larger than one.)

Blech.  I believe that floats and similar objects should never be
implicitly converted to indexes.  There are too many ways for silent
errors to get propagated.
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/



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