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

gh-130664: support '_' (just as ',') in Decimal's formatting#132155

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 2 commits intopython:mainfromskirpichev:decimal-underscore-sep/130664
Apr 15, 2025

Conversation

@skirpichev
Copy link
Contributor

@skirpichevskirpichev commentedApr 6, 2025
edited by bedevere-appbot
Loading

>>>from _decimalimport Decimalas D>>>format(D(1234567),'_')'1_234_567'>>>format(D(1234567),'020_')'0_000_000_001_234_567'>>>format(D('1234.56'),'07_')'1_234.56'>>>format(D('1.23456789'),'_')'1.23456789'>>>format(D('123.456789'),'_%')'12_345.6789%'>>>from _pydecimalimport Decimalas D>>>format(D(1234567),'_')'1_234_567'>>>format(D(1234567),'020_')'0_000_000_001_234_567'>>>format(D('1234.56'),'07_')'1_234.56'>>>format(D('1.23456789'),'_')'1.23456789'>>>format(D('123.456789'),'_%')'12_345.6789%'

```pycon>>> from _decimal import Decimal as D>>> format(D(1234567), '_')'1_234_567'>>> format(D(1234567), '020_')'0_000_000_001_234_567'>>> format(D('1234.56'), '07_')'1_234.56'>>> format(D('1.23456789'), '_')'1.23456789'>>> format(D('123.456789'), '_%')'12_345.6789%'>>> from _pydecimal import Decimal as D>>> format(D(1234567), '_')'1_234_567'>>> format(D(1234567), '020_')'0_000_000_001_234_567'>>> format(D('1234.56'), '07_')'1_234.56'>>> format(D('1.23456789'), '_')'1.23456789'>>> format(D('123.456789'), '_%')'12_345.6789%'```
@python-cla-bot
Copy link

All commit authors signed the Contributor License Agreement.

CLA signed

(',%','123.456789','12,345.6789%'),
(',e','123456','1.23456e+5'),
(',E','123456','1.23456E+5'),
# ... with '_' instead

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can we not just use the existing tests with afor loop?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What you meant? There is no existing test with'_' separator.

Copy link
Member

@StanFromIrelandStanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does this not need a documentation update somewhere too?

…F2r-U.rstCo-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@skirpichev
Copy link
ContributorAuthor

Does this not need a documentation update somewhere too?

We don't have documentation for Decimal's formatting, beyond some notes in theFormat Specification Mini-Language. There are no even examples of formatted output (few added in#128698).

@ambvambv merged commite10fe81 intopython:mainApr 15, 2025
39 checks passed
@skirpichevskirpichev deleted the decimal-underscore-sep/130664 branchApril 15, 2025 11:20
@skirpichevskirpichev added the needs backport to 3.13bugs and security fixes labelJul 14, 2025
@miss-islington-app
Copy link

Thanks@skirpichev for the PR, and@ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJul 14, 2025
…ythonGH-132155)(cherry picked from commite10fe81)Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
@bedevere-app
Copy link

GH-136649 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJul 14, 2025
picnixz pushed a commit that referenced this pull requestJul 14, 2025
…H-132155) (#136649)gh-130664: support '_' (just as ',') in Decimal's formatting (GH-132155)(cherry picked from commite10fe81)Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@StanFromIrelandStanFromIrelandStanFromIreland left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@skirpichev@StanFromIreland@ambv

[8]ページ先頭

©2009-2025 Movatter.jp