Skip to content

Commit

Permalink
Adjust signature of _from_pair() and add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Feb 11, 2023
1 parent 836d3a6 commit 3625d34
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Lib/fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,15 @@ def from_decimal(cls, dec):
return cls(*dec.as_integer_ratio())

@classmethod
def _from_pair(cls, num, den):
def _from_pair(cls, numerator, denominator, /):
"""Convert a pair of int's to a rational number.
The ratio of integers should be in lowest terms and
the denominator is positive.
"""
obj = super(Fraction, cls).__new__(cls)
obj._numerator = num
obj._denominator = den
obj._numerator = numerator
obj._denominator = denominator
return obj

def is_integer(self):
Expand Down

0 comments on commit 3625d34

Please sign in to comment.