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.
717
717
718
718
Return an integer object constructed from a number or string *x *, or return
719
719
``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.
722
725
723
726
If *x * is not a number or if *base * is given, then *x * must be a string,
724
727
: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
179
179
180
180
Return the :class: `~numbers.Real ` value *x * truncated to an
181
181
:class: `~numbers.Integral ` (usually an integer). Delegates to
182
- `` x.__trunc__() ` `.
182
+ :meth: ` x.__trunc__() <object.__trunc__> `.
183
183
184
184
185
185
Note 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.
2312
2312
of the appropriate type.
2313
2313
2314
2314
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
+
2315
2324
.. method :: object.__index__(self)
2316
2325
2317
2326
Called to implement :func: `operator.index `, and whenever Python needs to
You can’t perform that action at this time.
0 commit comments