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/2006-August/067913.html below:

[Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

[Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)James Y Knight foom at fuhm.net
Thu Aug 3 05:39:43 CEST 2006
On Aug 2, 2006, at 11:26 PM, Raymond Hettinger wrote:
> Also, -10 on changing the semantics of int() to round instead of
> truncate.  The truncating version is found is so many other languages
> and book examples, that it would be a disaster for us to choose a
> different meaning.

I'd be happy to see floats lose their __int__ method entirely,  
replaced by an explicit truncate function.

I've always thought it quite a hack that python floats have implicit  
truncation to ints, and then a random smattering of APIs go to extra  
lengths to explicitly prevent float.__int__ from being called because  
people thought "passing a float makes no sense!". That's right, it  
doesn't, and it _never_ should happen implicitly, not just in those  
particular few cases. Explicit is better than implicit.

James

More information about the Python-Dev mailing list

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