How do Fractions convert to int?

Robin Koch robin.koch at t-online.de
Tue Mar 13 07:40:26 EDT 2018


Am 13.03.2018 um 12:16 schrieb Steven D'Aprano:
> How do Fractions convert to ints when they have no __int__ method?

It uses __trunc__:
| In general, the int() conversion should try __int__() first and if
| it is not found, try 
__trunc__().[https://www.python.org/dev/peps/pep-3141/]
-- 
Robin Koch


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /