Title: `,` works with `Decimal()` against the doc of **Format Specification Mini-Language** · Issue #136636 · python/cpython · GitHub
Open Graph Title: `,` works with `Decimal()` against the doc of **Format Specification Mini-Language** · Issue #136636 · python/cpython
X Title: `,` works with `Decimal()` against the doc of **Format Specification Mini-Language** · Issue #136636 · python/cpython
Description: Bug report Bug description: The doc of Format Specification Mini-Language doesn't say that , works with Decimal() as shown below: ',': Inserts a comma every 3 digits for integer presentation type 'd' and floating-point presentation types...
Open Graph Description: Bug report Bug description: The doc of Format Specification Mini-Language doesn't say that , works with Decimal() as shown below: ',': Inserts a comma every 3 digits for integer presentation type '...
X Description: Bug report Bug description: The doc of Format Specification Mini-Language doesn't say that , works with Decimal() as shown below: ',': Inserts a comma every 3 digits for integer present...
Opengraph URL: https://github.com/python/cpython/issues/136636
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`,` works with `Decimal()` against the doc of **Format Specification Mini-Language**","articleBody":"# Bug report\n\n### Bug description:\n\n[The doc](https://docs.python.org/3/library/string.html#format-specification-mini-language) of **Format Specification Mini-Language** doesn't say that `,` works with [Decimal()](https://docs.python.org/3/library/decimal.html#decimal.Decimal) as shown below:\n\n\u003e ',': Inserts a comma every 3 digits for integer presentation type 'd' and floating-point presentation types, excluding 'n'. For other presentation types, this option is not supported.\n\nBut `,` works with `Decimal()` against the doc as shown below:\n\n```python\nfrom decimal import Decimal\n\nv = Decimal(value='1234.5555555555')\n\nprint('\"{:,.20f}\"'.format(v))\nprint('\"{:,.20F}\"'.format(v))\n# \"1,234.55555555550000000000\"\n# | 20 |\n\nprint('\"{:,f}\"'.format(v))\nprint('\"{:,F}\"'.format(v))\n# \"1,234.5555555555\"\n# | 10 |\n```\n\n```python\nfrom decimal import Decimal\n\nv = Decimal('123456.78912')\n\nprint('\"{:,.20g}\"'.format(v))\nprint('\"{:,.20G}\"'.format(v))\nprint('\"{:,.20}\"'.format(v))\nprint('\"{:,g}\"'.format(v))\nprint('\"{:,G}\"'.format(v))\nprint('\"{:,}\"'.format(v))\n# \"123,456.78912\"\n# | 11 |\n```\n\nIn addition, the doc doesn't say that `_` works with `Decimal()` as shown below:\n\n\u003e '_': Inserts an underscore every 3 digits for integer presentation type 'd' and floating-point presentation types, excluding 'n'. For integer presentation types 'b', 'o', 'x', and 'X', underscores are inserted every 4 digits. For other presentation types, this option is not supported.\n\nSo, `_` doesn't work with `Decimal()` as the doc doesn't say so as shown below:\n\n```python\nfrom decimal import Decimal\n\nv = Decimal(value='1234.5555555555')\n\nprint('\"{:_.20f}\"'.format(v))\nprint('\"{:_.20F}\"'.format(v))\nprint('\"{:_f}\"'.format(v))\nprint('\"{:_F}\"'.format(v))\n# ValueError: invalid format string\n```\n\n```python\nfrom decimal import Decimal\n\nv = Decimal('123456.78912')\n\nprint('\"{:_.20g}\"'.format(v))\nprint('\"{:_.20G}\"'.format(v))\nprint('\"{:_.20}\"'.format(v))\nprint('\"{:_g}\"'.format(v))\nprint('\"{:_G}\"'.format(v))\nprint('\"{:_}\"'.format(v))\n# ValueError: invalid format string\n```\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nWindows","author":{"url":"https://github.com/hyperkai","@type":"Person","name":"hyperkai"},"datePublished":"2025-07-13T22:10:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/136636/cpython/issues/136636"}
| 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:de767ed4-00c4-79c7-fe84-6bd782b390eb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D4DA:214CC9:804B69:B6037E:696A589A |
| html-safe-nonce | 1795ce0df8638c8c04ec3a8fdf720f56bb84520bad60fcbe4668d02ce457b1d8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENERBOjIxNENDOTo4MDRCNjk6QjYwMzdFOjY5NkE1ODlBIiwidmlzaXRvcl9pZCI6IjUyNjQwODAzNDI1OTM3MjI1MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dbc88b46378cdb80e85f222fccd944640eeab74b968db609c876a6a277dd5a9b |
| hovercard-subject-tag | issue:3226863745 |
| 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/136636/issue_layout |
| twitter:image | https://opengraph.githubassets.com/00f88da791350bc0a6b335640a7cbbd53f9b4666dd1ebe277b0e17ce1383dc2f/python/cpython/issues/136636 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/00f88da791350bc0a6b335640a7cbbd53f9b4666dd1ebe277b0e17ce1383dc2f/python/cpython/issues/136636 |
| og:image:alt | Bug report Bug description: The doc of Format Specification Mini-Language doesn't say that , works with Decimal() as shown below: ',': Inserts a comma every 3 digits for integer presentation type '... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hyperkai |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| 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 | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width