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/2008-January/076465.html below:

[Python-Dev] trunc()

[Python-Dev] trunc() [Python-Dev] trunc()Daniel Stutzbach daniel at stutzbachenterprises.com
Thu Jan 24 22:09:54 CET 2008
On Jan 24, 2008 12:46 PM, Guido van Rossum <guido at python.org> wrote:
> trunc() has well-defined semantics -- it takes a Real instance and
> converts it to an Integer instance using round-towards-zero semantics.
>
> int() has undefined semantics -- it takes any object and converts it
> to an int (a concrete type!) using whatever rules it likes -- the
> definition of __int__ is up to whatever the source type likes to do.

What are the use-cases for when trunc() vs int() should be used, and
for when a class should define __trunc__ vs __int__?

This might help clear up whether both deserve to be a built-in, as
well provide a starting point for 3.0 best practices.

-- 
Daniel Stutzbach, Ph.D.             President, Stutzbach Enterprises LLC
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