File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -717,8 +717,11 @@ are always available. They are listed here in alphabetical order.
717717
718718 Return an integer object constructed from a number or string *x *, or return
719719 ``0 `` if no arguments are given. If *x * is a number, return
720- :meth: `x.__int__() <object.__int__> `. For floating point numbers, this
721- truncates towards zero.
720+ :meth: `x.__int__() <object.__int__> `. If *x * defines
721+ :meth: `x.__trunc__() <object.__trunc__> ` but not
722+ :meth: `x.__int__() <object.__int__> `, then return
723+ if :meth: `x.__trunc__() <object.__trunc__> `. For floating point numbers,
724+ this truncates towards zero.
722725
723726 If *x * is not a number or if *base * is given, then *x * must be a string,
724727 :class: `bytes `, or :class: `bytearray ` instance representing an :ref: `integer
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ Number-theoretic and representation functions
179179
180180 Return the :class: `~numbers.Real ` value *x * truncated to an
181181 :class: `~numbers.Integral ` (usually an integer). Delegates to
182- `` x.__trunc__() ` `.
182+ :meth: ` x.__trunc__() <object.__trunc__> `.
183183
184184
185185Note that :func: `frexp ` and :func: `modf ` have a different call/return pattern
Original file line number Diff line number Diff line change @@ -2312,6 +2312,15 @@ left undefined.
23122312 of the appropriate type.
23132313
23142314
2315+ .. method :: object.__trunc__(self)
2316+
2317+ Called to implement :meth: `math.trunc `. Should return the value of the
2318+ object truncated to a :class: `numbers.Integral ` (typically an
2319+ :class: `int `). If a class defines :meth: `__trunc__ ` but not
2320+ :meth: `__int__ `, then :meth: `__trunc__ ` is called to implement the
2321+ built-in function :func: `int `.
2322+
2323+
23152324.. method :: object.__index__(self)
23162325
23172326 Called to implement :func: `operator.index `, and whenever Python needs to
You can’t perform that action at this time.
0 commit comments