Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fraction literals should support underscores in numbers and whitespace around numbers #96432

Closed
Labels
type-featureA feature request or enhancement
@rhettinger

Description

@rhettinger

To make fraction literals more readable, this should be made to work:Fraction('31_415_925_535 / 10_000_000_000')

PEP 515 – Underscores in Numeric Literals are well supported in all numeric types except for fractions. This works:1_234 andDecimal('1_234'). However, this is not accepted:Fraction('1_234').

Like decimals and ints, fractions support leading and trailing whitespace for string inputs:int(' 123 '),Decimal(' 123.4 '), andFraction(' 123/100 '). What is still needed is support for optional whitespace around the forward slash:Fraction('355 / 113'). This particular example came up when using the Fraction module to teach math to kids and where the string literal was obtained from callinginput().

Side note: If you writeprint(355/113) in your code, Black will reformat it toprint(355 / 113). Because of this, I expect that adults will also develop a preference for writing fractions with whitespace around the slash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp