Discussion:
[issue16944] German number separators not working using format language and locale "de_DE"
Peter Stahl
2013-01-12 11:26:56 UTC
Permalink
New submission from Peter Stahl:

Yesterday, I opened a question on Stackoverflow that explains my problem in detail. Please read this page first:

http://stackoverflow.com/questions/14287051/german-number-separators-using-format-language-on-osx
import locale
locale.setlocale(locale.LC_ALL, 'de_DE')
'{0:n}'.format(1234.56)
The result of the last expressions should be 1.234,56. However, my result is 1234,56. More examples are on Stackoverflow.

According to what other SO members have found out, this is a problem with the locale settings of OSX because the grouping of numbers is not fully part of the locale "de_DE". On Windows, however, grouping works fine using the locale "deu_deu" which is not available on OSX.

Is this a bug? At least, it doesn't seem to be documented anywhere and is probably not the correct behavior even on OSX. Others have reported similar problems on OSX as well.

Do you have a quick solution for this issue? Thanks in advance.

----------
components: Library (Lib)
messages: 179785
nosy: Peter.Stahl
priority: normal
severity: normal
status: open
title: German number separators not working using format language and locale "de_DE"
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16944>
_______________________________________
Stefan Krah
2013-01-12 11:39:14 UTC
Permalink
Stefan Krah added the comment:

What is the output of this?
locale.localeconv()
{'mon_decimal_point': ',', 'frac_digits': 2, 'p_sign_posn': 1, 'thousands_sep': '.', 'p_sep_by_space': 1, 'int_curr_symbol': 'EUR ', 'decimal_point': ',', 'mon_thousands_sep': '.', 'n_sep_by_space': 1, 'int_frac_digits': 2, 'currency_symbol': 'EUR', 'negative_sign': '-', 'mon_grouping': [3, 3, 0], 'positive_sign': '', 'n_cs_precedes': 0, 'grouping': [3, 3, 0], 'n_sign_posn': 1, 'p_cs_precedes': 0}


If 'grouping' is [], then this looks like a bug in OSX. Python gets
the values directly from the operating system.

----------
nosy: +skrah
status: open -> pending

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16944>
_______________________________________
Peter Stahl
2013-01-12 11:52:17 UTC
Permalink
Peter Stahl added the comment:

Using the locale 'de_DE', the output is:

{'mon_decimal_point': ',', 'int_frac_digits': 2, 'p_sep_by_space': 0, 'frac_digits': 2, 'thousands_sep': '', 'n_sign_posn': 1, 'decimal_point': ',', 'int_curr_symbol': 'EUR ', 'n_cs_precedes': 1, 'p_sign_posn': 1, 'mon_thousands_sep': '.', 'negative_sign': '-', 'currency_symbol': 'Eu', 'n_sep_by_space': 0, 'mon_grouping': [3, 3, 0], 'p_cs_precedes': 1, 'positive_sign': '', 'grouping': [127]}

What does the number 127 mean?
Post by Stefan Krah
What is the output of this?
locale.localeconv()
{'mon_decimal_point': ',', 'frac_digits': 2, 'p_sign_posn': 1, 'thousands_sep': '.', 'p_sep_by_space': 1, 'int_curr_symbol': 'EUR ', 'decimal_point': ',', 'mon_thousands_sep': '.', 'n_sep_by_space': 1, 'int_frac_digits': 2, 'currency_symbol': 'EUR', 'negative_sign': '-', 'mon_grouping': [3, 3, 0], 'positive_sign': '', 'n_cs_precedes': 0, 'grouping': [3, 3, 0], 'n_sign_posn': 1, 'p_cs_precedes': 0}
If 'grouping' is [], then this looks like a bug in OSX. Python gets
the values directly from the operating system.
----------
nosy: +skrah
status: open -> pending
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16944>
_______________________________________
----------
status: pending -> open

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16944>
_______________________________________
Stefan Krah
2013-01-12 12:24:31 UTC
Permalink
Stefan Krah added the comment:

127 means "no-more-grouping", so Python behaves as instructed by the OS.

As you see, the OS prescribes 1.345.677,222 for *monetary* quantities
and 1345677,222 otherwise.

According to http://de.wikipedia.org/wiki/DIN_1333 , for non monetary
quantities DIN-1333 says *empty spaces* *may* be used as separators.
DIN-5008 says they *should* be used. :)


Most operating systems use [3, 3, 0] also for de_DE 'grouping', but
given the unclear situation it's hard to claim a bug in OSX.


The only way out of this would be to introduce a new 'm' locale specifier
that uses mon_grouping.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16944>
_______________________________________
Eric V. Smith
2013-01-14 16:31:00 UTC
Permalink
Eric V. Smith added the comment:

I think this issue should be closed, since we're doing as we're instructed by the OS. If someone wants to open a new issue for the "m" format specifier type, I'd support that.

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16944>
_______________________________________
Stefan Krah
2013-01-14 16:49:42 UTC
Permalink
Stefan Krah added the comment:

I agree, we can't really do anything here.

----------
resolution: -> invalid
stage: -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16944>
_______________________________________

Loading...