Message309299
> In what scenario would the numerator and denominator be numbers.Rational but not an integer or a fraction
But that's not the issue here. The issue here is having an instance of `numbers.Rational` whose numerator and denominator are not specifically of concrete type `int`: the test that (IIUC) you're proposing to remove is:
if type(numerator) is int is type(denominator):
[...]
Certainly I'd expect the numerator and denominator to be instances of `numbers.Integral`, but that's more general than being of exact type `int`.
The `numbers.Integral` and `numbers.Rational` ABCs are deliberately not tied to particular concrete classes. It would be perfectly possible (and reasonable) for someone to have a `MyFraction` class that behaves like a `Fraction`, and whose numerator and denominator are instances of some other concrete class `MyInteger` that behaves like an integer.
The branch in the code is necessary to support that situation, so we can't simply remove it. |
|
Date |
User |
Action |
Args |
2017-12-31 19:33:10 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, gphemsley |
2017-12-31 19:33:10 | mark.dickinson | set | messageid: <1514748790.27.0.467229070634.issue32466@psf.upfronthosting.co.za> |
2017-12-31 19:33:10 | mark.dickinson | link | issue32466 messages |
2017-12-31 19:33:09 | mark.dickinson | create | |
|