Author vstinner
Recipients eric.smith, mark.dickinson, serhiy.storchaka, skrah, steelman, vstinner
Date 2019-01-09.00:51:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Ł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:

Stefan Krah:
> My main concern with 'm' for libmpdec is that I'd like to reserve it

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":


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 but I abandonned my change.
Date User Action Args
2019-01-09 00:52:00vstinnersetrecipients: + vstinner, mark.dickinson, eric.smith, skrah, serhiy.storchaka, steelman
2019-01-09 00:51:59vstinnersetmessageid: <>
2019-01-09 00:51:59vstinnerlinkissue35638 messages
2019-01-09 00:51:59vstinnercreate