[Numpy-discussion] Greek Letters

Mark Janikas mjanikas@esri....
Tue Feb 20 19:16:23 CST 2007

Thanks Robert.... but alas, I get.....

>>> import sys
>>> sys.stdout.encoding
>>> print u'\u03a7\u00b2'.encode(sys.stdout.encoding)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python24\lib\encodings\cp437.py", line 18, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u03a7' in position
 0: character maps to <undefined>

Ill keep at it.... please let me know if you have any solutions....

Thanks again,


-----Original Message-----
From: numpy-discussion-bounces@scipy.org [mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Robert Kern
Sent: Tuesday, February 20, 2007 4:20 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] Greek Letters

Mark Janikas wrote:
> Hello all,
> I was wondering how I could print the chi-squared symbol in python.  I
> have been looking at the Unicode docs, but I figured I would ask for
> assistance here while I delve into it.  Thanks for any help in advance.

Print it where? To the terminal (which one?)? In HTML? With some GUI?

Assuming that you have a Unicode-capable terminal, you can find out the encoding
it uses by looking at sys.stdout.encoding. Encode your Unicode string with that
encoding, and print it. E.g., I use iTerm on OS X and set it to use UTF-8 as the

In [5]: import sys

In [6]: sys.stdout.encoding
Out[6]: 'UTF-8'

In [7]: print u'\u03a7\u00b2'.encode(sys.stdout.encoding)

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco
Numpy-discussion mailing list

More information about the Numpy-discussion mailing list