Bug: (Locale) IDLE/Tkinter/Python?

Fredrik Lundh fredrik at pythonware.com
Thu Oct 7 09:53:23 EDT 1999


Adrian Eyre <a.eyre at optichrome.com> wrote:
> So how come it's okay to set the locale in Python. Surely this just calls
> the equivalent function in C.

nope.  or rather, it does more than that.  here's
some psuedocode:

def setlocale(category, locale):
    global grouping, thousands_sep, decimal_point

    c.setlocale(category, locale)

    if category in (LC_NUMERIC, LC_ALL):
        # record changes to LC_NUMERIC
        lc = c.localeconv()
        grouping = lc.grouping
        thousands_sep = lc.thousands_sep
        decimal_point = lc.decimal_point    
        c.setlocale(LC_NUMERIC, "C")

or in other words, it changes it all, extracts
the numeric values, and resets the numeric
locale.

the locale module then provides versions of
atof, atoi (and others) that take these values
into account.

</F>





More information about the Python-list mailing list