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 @@ -731,8 +731,11 @@ are always available. They are listed here in alphabetical order.
731731
732732 Return an integer object constructed from a number or string *x *, or return
733733 ``0 `` if no arguments are given. If *x * is a number, return
734- :meth: `x.__int__() <object.__int__> `. For floating point numbers, this
735- truncates towards zero.
734+ :meth: `x.__int__() <object.__int__> `. If *x * defines
735+ :meth: `x.__trunc__() <object.__trunc__> ` but not
736+ :meth: `x.__int__() <object.__int__> `, then return
737+ if :meth: `x.__trunc__() <object.__trunc__> `. For floating point numbers,
738+ this truncates towards zero.
736739
737740 If *x * is not a number or if *base * is given, then *x * must be a string,
738741 :class: `bytes `, or :class: `bytearray ` instance representing an :ref: `integer
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ Number-theoretic and representation functions
203203
204204 Return the :class: `~numbers.Real ` value *x * truncated to an
205205 :class: `~numbers.Integral ` (usually an integer). Delegates to
206- `` x.__trunc__() ` `.
206+ :meth: ` x.__trunc__() <object.__trunc__> `.
207207
208208
209209Note that :func: `frexp ` and :func: `modf ` have a different call/return pattern
Original file line number Diff line number Diff line change @@ -2377,6 +2377,15 @@ left undefined.
23772377 of the appropriate type.
23782378
23792379
2380+ .. method :: object.__trunc__(self)
2381+
2382+ Called to implement :meth: `math.trunc `. Should return the value of the
2383+ object truncated to a :class: `numbers.Integral ` (typically an
2384+ :class: `int `). If a class defines :meth: `__trunc__ ` but not
2385+ :meth: `__int__ `, then :meth: `__trunc__ ` is called to implement the
2386+ built-in function :func: `int `.
2387+
2388+
23802389.. method :: object.__index__(self)
23812390
23822391 Called to implement :func: `operator.index `, and whenever Python needs to
You can’t perform that action at this time.
0 commit comments