This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Format Specification Mini-Language does not accept comma for percent value
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: eric.araujo, eric.smith, ezio.melotti, mkesper, skrah
Priority: normal Keywords:

Created on 2012-01-06 11:24 by mkesper, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg150721 - (view) Author: Michael Kesper (mkesper) Date: 2012-01-06 11:23
http://docs.python.org/library/string.html#format-specification-mini-language mentions:
Changed in version 2.7: Added the ',' option (see also PEP 378).

PEP 378 tells me:
The ',' option is defined as shown above for types 'd', 'e', 'f', 'g', 'E', 'G', '%', 'F' and ''.

However:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> '{:.2,%}'.format(.537568)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Invalid conversion specification
>>> '{:2,%}'.format(.537568)
'53.756800%'
msg150956 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-01-09 17:00
FTR the doc for ',' was added in a6e7ed52df9b and fa16acb2ffdd.
msg150962 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-01-09 18:43
[[fill]align][sign][#][0][width][,][.precision][type]

The ',' must be before [.precision]:

>>> '{:,.2%}'.format(55.537568)
'5,553.76%'


In my opinion this is not a bug.
msg150989 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-01-10 00:09
Good point. I hadn't looked at the string closely enough. Closing.
History
Date User Action Args
2022-04-11 14:57:25adminsetgithub: 57927
2012-01-10 00:09:41eric.smithsetstatus: open -> closed
resolution: not a bug
messages: + msg150989

stage: resolved
2012-01-09 18:43:16skrahsetnosy: + skrah
messages: + msg150962
2012-01-09 17:00:54eric.araujosetnosy: + eric.araujo
messages: + msg150956
2012-01-06 15:20:06eric.smithsetassignee: eric.smith
2012-01-06 15:11:39ezio.melottisetnosy: + eric.smith, ezio.melotti
2012-01-06 11:24:00mkespercreate