homepage

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: str.format() :n format does not appear to work for int and float
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: eric.smith, mark, nnorwitz
Priority: high Keywords:

Created on 2008年04月01日 11:35 by mark, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (5)
msg64804 - (view) Author: Mark Summerfield (mark) * Date: 2008年04月01日 11:35
>>> # Py30a3
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "en_US.UTF8")
'en_US.UTF8'
>>> locale.format("%d", 12345, True)
'12,345'
>>> "{0:n}".format(12345)
'12345'
According to the docs the 'n' format should use the locale-dependent
separator, so I expected both strings to be '12,345'.
Also, it is a pity that locale.format() uses the old deprecated % syntax
rather than the much nicer and better str.format() syntax.
msg64959 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2008年04月05日 02:59
Eric, could you take a look?
msg64968 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2008年04月05日 10:49
I'm looking into it.
msg64974 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2008年04月05日 14:35
The same issue exists with floats:
# continuing the example
>>> locale.format("%g", 12345, True)
'12,345'
>>> "{0:n}".format(12345.0)
'12345'
The same issue exists in 2.6.
msg65988 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2008年04月30日 01:10
Committed fix in r62586.
History
Date User Action Args
2022年04月11日 14:56:32adminsetgithub: 46778
2008年04月30日 01:10:18eric.smithsetstatus: open -> closed
resolution: fixed
messages: + msg65988
2008年04月05日 14:35:32eric.smithsettitle: str.format() :n format does not appear to work -> str.format() :n format does not appear to work for int and float
messages: + msg64974
versions: + Python 2.6
2008年04月05日 10:49:50eric.smithsetmessages: + msg64968
2008年04月05日 02:59:06nnorwitzsetpriority: high
assignee: eric.smith
messages: + msg64959
nosy: + eric.smith, nnorwitz
2008年04月01日 11:35:24markcreate

AltStyle によって変換されたページ (->オリジナル) /