I'm trying to print a number in a scientific number format (with exponent) using the package babel
and a German locale:
>>> from babel.numbers import format_scientific
>>> x = 123456.789
>>> format_scientific(x, format="0.000E0", locale="de_DE")
'1.235E5'
I would have expected an output of '1,235E5'
instead (note the comma instead of the point as the decimal seperator). Maybe format_scientific
isn't supposed to be called directly, and I have more luck with format_decimal
? Nope:
>>> from babel.numbers import format_decimal
>>> format_decimal(x, format="0.000E0", locale="de_DE")
'1.235E5'
I've tested it with Python 3.6 and Babel 2.3.4. This isn't the latest version of Babel, but their changelog doesn't indicate that they've fixed a big, glaring error in their handling of the scientific format, nor did I find anything on their bugtracker. Since it seems unlikely that such an error would go unnoticed, I'm obviously doing something wrong or operate under some faulty assumption.