[Numpy-discussion] trouble with locale in combination with numpy and pylab

Achim Gaedke Achim.Gaedke@physik.tu-darmstadt...
Mon Sep 15 11:11:06 CDT 2008

Hi there!

Consider this python program (saved as locale_trouble.py):

import numpy
print a, float(a)
import gtk
print a, float(a)

everything is fine, if you call this program as follows:

LANG="C" python locale_trouble.py
1.2 1.20000004768
1.2 1.20000004768

LANG="de_DE" python locale_trouble.py
1.2 1.20000004768
1,2 1.20000004768

The coma in the last line is unexpected.

This error also occurs when using pylab or matplotlib with gtk backend:

import pylab
print pylab.rcParams["backend"]

This behaviour is observed with debian lenny and python 2.4 and python
2.5,  numpy-1.1.0 and numpy-1.1.1 . On debian etch with numpy-1.0.1 we
were not able to provoke a coma.

This behaviour is highly irritating, so we believe that is a bug.
Following the python policy to use a dot for numbers, independent of
locale definitions. See note (3) on page:

Yours, Achim

More information about the Numpy-discussion mailing list