Strange behaviour of floating point constants in imported modules

Tomasz Lisowski tomlis at notmyisp.pl
Wed May 25 04:08:23 EDT 2005


> This may be relevant to the problems you're seeing:
>     https://sourceforge.net/tracker/?func=detail&atid=305470&aid=774665&group_id=5470
> 
> The short story, as the tracker item paints it, is that setting
> LC_NUMERIC to anything other than 'C' can give results like the ones you
> describe---Python itself should never do this, but third parties code
> may.
> 
> A web search for python LC_NUMERIC should turn up more about this topic,
> probably even some past threads on this mailing list/newsgroup.

You've got the point. My code uses wxLocale class from wxPython, and 
sets the wxLANGUAGE_POLISH locale. After setting this locale, I have 
added the statement:

locale.setlocale(locale.LC_NUMERIC, "C")

and everything seems to be normal now. I agree with the comments in the 
tracker item, that the float, str(), repr() functions should be 
locale-independent. We have the functions in the locale module, if 
someone needs the locale-dependent string-float conversions.

-- 
Tomasz Lisowski



More information about the Python-list mailing list