diff options
author | Shantanu <12621235+hauntsaninja@users.noreply.github.com> | 2023-01-01 08:44:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-01 08:44:48 (GMT) |
commit | e83f88a455261ed53530a960f1514ab7af7d2e82 (patch) | |
tree | 6808b9d24a7483d4afb9c7df262470b2a06e7618 /Lib/fractions.py | |
parent | 71159a8e078bda0c9a39c6cd0980b7ba238dc582 (diff) | |
download | cpython-e83f88a455261ed53530a960f1514ab7af7d2e82.zip cpython-e83f88a455261ed53530a960f1514ab7af7d2e82.tar.gz cpython-e83f88a455261ed53530a960f1514ab7af7d2e82.tar.bz2 |
gh-100488: Add is_integer method to fractions.Fraction (#100489)
Diffstat (limited to 'Lib/fractions.py')
-rw-r--r-- | Lib/fractions.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/fractions.py b/Lib/fractions.py index 75c7df1..4302f3f 100644 --- a/Lib/fractions.py +++ b/Lib/fractions.py @@ -225,6 +225,10 @@ class Fraction(numbers.Rational): (cls.__name__, dec, type(dec).__name__)) return cls(*dec.as_integer_ratio()) + def is_integer(self): + """Return True if the Fraction is an integer.""" + return self._denominator == 1 + def as_integer_ratio(self): """Return the integer ratio as a tuple. |