A python IDE for teaching that supports cyrillic i/o

Kirill Simonov xi at gamma.dn.ua
Mon Nov 20 12:29:44 CET 2006


On Sun, Nov 19, 2006 at 02:54:33PM -0800, Leo Kislov wrote:
> Kirill Simonov wrote:
> > On Sun, Nov 19, 2006 at 03:27:32AM -0800, Leo Kislov wrote:
> > > IDLE on Windows works fine for your example in interactive console:
> > >
> > > >>> name = raw_input("What's your name? ")
> >
> > Have you tried to use cyrillic characters in a Python string in
> > interactive console? When I do it, I get the "Unsupported characters in
> > input" error. For instance,
> >
> > >>> print "Привет"  # That's "Hi" in Russian.
> > Unsupported characters in input
> 
> That works for me in Win XP English, with Russian locale and Russian
> language for non-unicode programs. Didn't you say you want to avoid
> unicode? If so, you need to set proper locale and language for
> non-unicode programs.

Thanks. After I set Russian language for non-unicode programs, the
`print "Привет"` expression started to work correctly.

On the other hand,
    >>> print u"Привет"
doesn't display "Привет". The output looks like a CP1251-encoded string
was displayed using the latin1 character set.

It seems that the interactive interpreter in IDLE uses the CP1251
codepage.

> > Anyway, I just want the interactive console of an IDE to behave like a
> > real Python console under a UTF-8 terminal (with sys.stdout.encoding ==
> > 'utf-8').
> 
> Do you realize that utf-8 locale makes len() function and slicing of
> byte strings look strange for high school students?
> 
> hi = u"Привет".encode("utf-8")
> r = u"р".encode("utf-8")
> print len(hi)        # prints 12
> print hi[1] == r   # prints False
> for char in hi:
>     print char      # prints garbage
 
No, it slipped off my mind...

> As I see you have several options:
> 1. Set Russian locale and Russian language for non-unicode programs on
> Windows.

I guess I will go this route.  Looks that IDLE works reasonable well in
CP1251 locale.


Thanks,
Kirill



More information about the Python-list mailing list