Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add class method Fraction.from_number() #121797

Open
serhiy-storchaka opened this issue Jul 15, 2024 · 0 comments
Open

Add class method Fraction.from_number() #121797

serhiy-storchaka opened this issue Jul 15, 2024 · 0 comments
Labels
3.14 new features, bugs and security fixes type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jul 15, 2024

Feature or enhancement

It is an alternate constructor which only accepts a single numeric argument. Unlike to Fraction.from_float() and Fraction.from_decimal() it accepts any real numbers supported by the standard constructor (int, float, Decimal, Rational numbers). Unlike to the standard constructor, it does not accept strings.

Similar to float.from_number() and complex.from_number() (see #84978).

Linked PRs

@serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement 3.14 new features, bugs and security fixes labels Jul 15, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jul 15, 2024
It is an alternative constructor which only accepts a single numeric argument.
Unlike to Fraction.from_float() and Fraction.from_decimal() it accepts any
real numbers supported by the standard constructor (int, float, Decimal,
Rational numbers).
Unlike to the standard constructor, it does not accept strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 new features, bugs and security fixes type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant