[docs] [issue26701] Documentation for int constructor mentions __int__ but not __trunc__

Nick Coghlan report at bugs.python.org
Sat Mar 10 04:03:27 EST 2018


Nick Coghlan <ncoghlan at gmail.com> added the comment:

I think __trunc__ is special here, as it's called by a built-in type constructor, whereas __floor__ and __ceil__ really are specific to their respective math module functions. That said, I also wouldn't be opposed to listing all 4 methods together (or else listing __floor__ and __ceil__ with the just added entry for __trunc__).

I also filed https://bugs.python.org/issue33039 to cover an anomaly Eric found after I suggested adding __index__ to the list of methods tried, which is that int() and math.trunc() *don't* call __index__ implicitly: the type has to set "__int__ = __index__" and "__trunc__ = __index__" to get them to work.

I suspect we just didn't notice when PEP 357 was implemented because the developers that wanted __index__ were adding it to types that *already* defined __int__ and __trunc__.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue26701>
_______________________________________


More information about the docs mailing list