New submission from de la Musse:

locale.format function delete spaces in result which is a problem when
thousand separator is space (in French for example).

The problem seems in the code below (extract from locale.py):

145     while seps:
146         # If the number was formatted for a specific width, then it
147         # might have been filled with spaces to the left or right. If
148         # so, kill as much spaces as there where separators.
149         # Leading zeroes as fillers are not yet dealt with, as it is
150         # not clear how they should interact with grouping.
151         sp = result.find(" ")
152         if sp==-1:break
153         result = result[:sp]+result[sp+1:]
154         seps -= 1

Example :

>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC)
'C'
>>> locale.setlocale(locale.LC_NUMERIC, "fr_FR.UTF-8")
'fr_FR.UTF-8'
>>> locale.format("%.2f", 12345.67, True)
'12345,67'

The correct result is '12 345,67' not '12345,67'

and if I call

>>> locale.format("%9.2f", 12345.67, True)
'12 345,67'

the result is correct

Is this behavior correct or a bug?

----------
nosy: +edlm10

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1222>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to