STINNER Victor <vstin...@redhat.com> added the comment: Łukasz Stelmach: > It is currently impossible to format floating point numbers with an arbitrary > number of decimal digits AND the decimal point matching locale settings.
I would like to warn you that handling properly locales can be very tricky. I just wrote an article about that: https://vstinner.github.io/locale-bugfixes-python3.html Stefan Krah: > My main concern with 'm' for libmpdec is that I'd like to reserve it for LC_MONETARY. Since it seems like we are still at the "idea" stage, would it make sense to add a function which accept options to choose how to format a number? * decimal point * thousands separator * grouping Because there are more and more format variants. See for example Python/formatter_unicode.c. It has 5 "locale types": * LT_NO_LOCALE * LT_DEFAULT_LOCALE * LT_UNDERSCORE_LOCALE * LT_UNDER_FOUR_LOCALE * LT_CURRENT_LOCALE and it uses this structure: /* Locale info needed for formatting integers and the part of floats before and including the decimal. Note that locales only support 8-bit chars, not unicode. */ typedef struct { PyObject *decimal_point; PyObject *thousands_sep; const char *grouping; char *grouping_buffer; } LocaleInfo; There is the locale but also "underscore" separator for thousands: see PEP 515. I'm not talking about adding something into format(), but add a method to float maybe. Or add a function somewhere else. -- By the way, the decimal module doesn't support properly the following corner case: LC_NUMERIC using an encoding different than LC_CTYPE encoding. I wrote https://github.com/python/cpython/pull/5191 but I abandonned my change. ---------- nosy: +vstinner _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35638> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com