Title: Fraction literals should support underscores in numbers and whitespace around numbers · Issue #96432 · python/cpython · GitHub
Open Graph Title: Fraction literals should support underscores in numbers and whitespace around numbers · Issue #96432 · python/cpython
X Title: Fraction literals should support underscores in numbers and whitespace around numbers · Issue #96432 · python/cpython
Description: 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 a...
Open Graph Description: 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 e...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/96432
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fraction literals should support underscores in numbers and whitespace around numbers","articleBody":"To make fraction literals more readable, this should be made to work: `Fraction('31_415_925_535 / 10_000_000_000')`\r\n\r\n[PEP 515 – Underscores in Numeric Literals](https://peps.python.org/pep-0515/) are well supported in all numeric types except for fractions. This works: `1_234` and `Decimal('1_234')`. However, this is not accepted: `Fraction('1_234')`. \r\n\r\nLike decimals and ints, fractions support leading and trailing whitespace for string inputs: `int(' 123 ')`, `Decimal(' 123.4 ')`, and `Fraction(' 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 calling `input()`.\r\n\r\nSide note: If you write `print(355/113)` in your code, Black will reformat it to `print(355 / 113)`. Because of this, I expect that adults will also develop a preference for writing fractions with whitespace around the slash.","author":{"url":"https://github.com/rhettinger","@type":"Person","name":"rhettinger"},"datePublished":"2022-08-30T15:52:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/96432/cpython/issues/96432"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:136627d3-6e1e-4c66-a408-10a5ad3f7822 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A37C:388B78:21D221A:2C1E468:696B4D27 |
| html-safe-nonce | 1c5da441eacba9699d2269ac954ce463698477ecae046faad95ed753d8b7d5dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzdDOjM4OEI3ODoyMUQyMjFBOjJDMUU0Njg6Njk2QjREMjciLCJ2aXNpdG9yX2lkIjoiNDQ0NDg2NzUzNjIwOTI2ODAwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2109c18daf6c347c74e817f148ef01c854da4b48c615c1f634448e08965276ed |
| hovercard-subject-tag | issue:1355980027 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/96432/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe1819366b4f819af878547d872a0435ce362fa4047bafe7057002bb641f2235/python/cpython/issues/96432 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe1819366b4f819af878547d872a0435ce362fa4047bafe7057002bb641f2235/python/cpython/issues/96432 |
| og:image:alt | 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 e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rhettinger |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width