Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adjust signature of _from_pair() and add docstring
  • Loading branch information
skirpichev committed Feb 11, 2023
commit 3625d34155b4d6d8665c665a85ccd701af47d336
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, /):
Comment thread
skirpichev marked this conversation as resolved.
Outdated
"""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