Mark Dickinson <dicki...@gmail.com> added the comment:
Thanks, that's helpful. I guess what you _really_ want there is a duck-typed "tell me whether this value is integral and if so give me the corresponding Python int", but that's not currently easily available, so I suppose x == int(x) is the next-best thing. Possibly the "right" way from the point of view of PEP 3141 is to be testing x == math.trunc(x) instead and asking for typing.SupportsTrunc, but it seems to me that __trunc__ never did really take off the way it was intended to. tl;dr: I agree it would make sense to add __int__ to fractions.Fraction for 3.11. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44547> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com