Message396868
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. |
|
| Date |
User |
Action |
Args |
| 2021-07-02 16:47:22 | mark.dickinson | set | recipients:
+ mark.dickinson, mamrhein, josh.r |
| 2021-07-02 16:47:22 | mark.dickinson | set | messageid: <1625244442.51.0.622248096908.issue44547@roundup.psfhosted.org> |
| 2021-07-02 16:47:22 | mark.dickinson | link | issue44547 messages |
| 2021-07-02 16:47:22 | mark.dickinson | create | |
|