[wxPython 2.3.1] what's going on?

Tim Peters tim.one at comcast.net
Tue Mar 19 11:03:26 EST 2002


[Pawel Oleksik]
> Playing with wxPython modules I've found something -- perhaps bug.
> Importing from wxPython.wx changes the calculation rules.
> Here is an example (strictly based on the random.py self-verification):
>
> (Linux, glibc-2.2.5, wxGTK-2.3.1, wxPython-2.3.1)
>
>
> Python 2.1.1 (#1, Aug 26 2001, 02:52:19)
> [GCC 2.95.3 20010315 (release)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import math
> >>> 4*math.exp(-0.5)/math.sqrt(2.0)
> 1.7155277699214135
> >>> from wxPython.wx import *
> >>> 4*math.exp(-0.5)/math.sqrt(2.0)
> 2,8284271247461898
   ^

> Has anybody met this problem, or it's just my 'private reslult' :)

That comma in the output is A Clue:  somehow or other, importing stuff from
wxPython is changing your locale, which in turn causes "-0.5" to be treated
as 0 (the answer you got is correct for 4*exp(0)/sqrt(2)).

Do a google search on

    wxPython locale

for more clues; it may or may not be a GTK bug, and the most frequently
suggested cure (I haven't tried it) is to do

import locale
locale.setlocale(locale.LC_ALL, "")

after importing stuff from wxPython.wx.





More information about the Python-list mailing list