[Numpy-discussion] Greek Letters
Mark Janikas
mjanikas@esri....
Tue Feb 20 19:29:25 CST 2007
Oh. I am using CygWin, and the website I just went to:
http://www.cygwin.com/faq/faq_3.html
stated that: " The short answer is that Cygwin is not Unicode-aware"
Not sure if this is going to apply to python in general, but I suspect it will. Ugh, I dislike Windows a lot, but it pays the bills. The interesting thing to note is that the print out to gui interface is 'UTF-8' so it works. It just wont work on my terminal where I do all of my testing. I might just have to put a try statement in and put a "chi-square" in the except.
MJ
-----Original Message-----
From: numpy-discussion-bounces@scipy.org [mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Mark Janikas
Sent: Tuesday, February 20, 2007 5:16 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] Greek Letters
Thanks Robert.... but alas, I get.....
>>> import sys
>>> sys.stdout.encoding
'cp437'
>>> 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,
MJ
-----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
encoding:
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
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
More information about the Numpy-discussion
mailing list