473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A python IDE for teaching that supports cyrillic i/o

Hi,

Could anyone suggest me a simple IDE suitable for teaching Python as a
first programming language to high school students? It is necessary
that it has a good support for input/output in Cyrillic.

Unfortunately, most IDEs I tried failed miserably in this respect. My
test was simple: I've run the code
name = raw_input("What's your name? ") # written in Russian
print "Hello, %s!" % name # in Russian as well
both from the shell and as a standalone script. This either caused a
UnicodeError or just printed invalid characters.

For the record, I've checked IDLE, PythonWin, Eric, DrPython, SPE, and
WingIDE. The only ones that worked are WingIDE and IDLE (under Linux,
but not under Windows).
Thanks,
Kirill
Nov 18 '06 #1
8 3633
Kirill Simonov wrote:
Hi,

Could anyone suggest me a simple IDE suitable for teaching Python as a
first programming language to high school students? It is necessary
that it has a good support for input/output in Cyrillic.

Unfortunately, most IDEs I tried failed miserably in this respect. My
test was simple: I've run the code
name = raw_input("What's your name? ") # written in Russian
print "Hello, %s!" % name # in Russian as well
both from the shell and as a standalone script. This either caused a
UnicodeError or just printed invalid characters.

For the record, I've checked IDLE, PythonWin, Eric, DrPython, SPE, and
WingIDE. The only ones that worked are WingIDE and IDLE (under Linux,
but not under Windows).
IDLE on Windows works fine for your example in interactive console:
>>name = raw_input("What's your name? ")
What's your name? Леонид
>>print name
Леонид
>>name
u'\u041b\u0435\u043e\u043d\u0438\u0434'

and as a script:

What's your name? Леонид
Hello, Леонид!
<type 'unicode'>
>>>
That is IDLE + python 2.4 on Windows. So I'm not sure what is the
problem. In other messages you seems to be talking about system
console. Why? It's not part of IDE.

And another question: are you aware of the fact that recommended way to
handle non-ascii characters is to use unicode type? Most of IDEs should
work fine with unicode.

-- Leo

Nov 19 '06 #2
Kirill Simonov si è divertito a scrivere:
Unfortunately, most IDEs I tried failed miserably in this respect. My
test was simple: I've run the code
name = raw_input("What's your name? ") # written in Russian
print "Hello, %s!" % name # in Russian as well
both from the shell and as a standalone script. This either caused a
UnicodeError or just printed invalid characters.
I highly dislike asking stupid questions, and this might be stupid
indeed... but did you write

# -*- coding: iso-8859-5 -*-

or

# -*- coding: koi8_r -*-

(they both seem suited to the Russian language, but I don't know the
difference)

as the first line in your .py file?

Personally, I use Eclipse+Pydev (a bit steep to learn at the beginning, and
quite memory and cpu hogging since it's a java-based ide; don't use it on
old/slow computers with less than 512MB RAM, and don't use version < 3.2
either) and it uses that very line to recognize the actual character set
employed. You may check with other encodings as well.

http://docs.python.org/lib/standard-encodings.html

It does work on Windows indeed.

UPDATE:
I tried with Eclipse+Pydev, and using koi8_r I seems to be able to simply
copy&paste a piece of the ixbt.com homepage in the editor I can save and
use it correctly.
--
Alan Franzoni <al***************@gmail.com>
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
Nov 19 '06 #3
On Sun, Nov 19, 2006 at 12:33:39PM +0100, Alan Franzoni wrote:
Kirill Simonov si è divertito a scrivere:
Unfortunately, most IDEs I tried failed miserably in this respect. My
test was simple: I've run the code
name = raw_input("What's your name? ") # written in Russian
print "Hello, %s!" % name # in Russian as well
both from the shell and as a standalone script. This either caused a
UnicodeError or just printed invalid characters.

I highly dislike asking stupid questions, and this might be stupid
indeed... but did you write

# -*- coding: iso-8859-5 -*-

or

# -*- coding: koi8_r -*-

(they both seem suited to the Russian language, but I don't know the
difference)
They are different encodings for the same character set. The latter is
mostly used under Unices, and the former is not used anywhere as far as
I know. There are two more cyrillic encodings: cp866 and cp1251 - for
DOS and Windows correspondingly.
as the first line in your .py file?
No, I would prefer the editor to save the .py files with non-ASCII
characters in UTF-8 encoding adding the BOM at the beginning of the
file. This will allow the interpreted to detect the file encoding
correctly and would save a teacher from explaining what an encoding is
and why it is needed.
Personally, I use Eclipse+Pydev (a bit steep to learn at the beginning, and
quite memory and cpu hogging since it's a java-based ide; don't use it on
old/slow computers with less than 512MB RAM, and don't use version < 3.2
either) and it uses that very line to recognize the actual character set
employed. You may check with other encodings as well.
Unfortunately, the Eclipse CPU/memory requirements are extremely high
for a high school, so I haven't even tried it.
--
xi
Nov 19 '06 #4
Kirill Simonov si è divertito a scrivere:
On Sun, Nov 19, 2006 at 12:33:39PM +0100, Alan Franzoni wrote:
No, I would prefer the editor to save the .py files with non-ASCII
characters in UTF-8 encoding adding the BOM at the beginning of the
file. This will allow the interpreted to detect the file encoding
correctly and would save a teacher from explaining what an encoding is
and why it is needed.
You'll run into encoding problems anyway in your programmer's life. I don't
think it's a workaround, try this article:

http://www.joelonsoftware.com/articles/Unicode.html

I think it's highly useful, you could tell that to your students.

BTW, not every editor supports the BOM. Have you tried with the explicit
encoding line:

# -*- coding: utf-8 -*-

Eclipse+Pydev seems to work with that. I'm not able to check with other
editors right now, but it seems you're experiencing a simple encoding
problem; your editor doesn't know which encoding you'd like to use, so it
defaults to ascii or iso-8859-1 leading to such problems.

--
Alan Franzoni <al***************@gmail.com>
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
Nov 19 '06 #5
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
>>>
And another question: are you aware of the fact that recommended way to
handle non-ascii characters is to use unicode type? Most of IDEs should
work fine with unicode.
Usually using unicode type gives you much more headache than benefits
unless you are careful enough to never mix unicode and str objects.

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').
Thanks,
Kirill
Nov 19 '06 #6
On Sun, Nov 19, 2006 at 03:13:30PM +0100, Alan Franzoni wrote:
Kirill Simonov si è divertito a scrivere:
On Sun, Nov 19, 2006 at 12:33:39PM +0100, Alan Franzoni wrote:
No, I would prefer the editor to save the .py files with non-ASCII
characters in UTF-8 encoding adding the BOM at the beginning of the
file. This will allow the interpreted to detect the file encoding
correctly and would save a teacher from explaining what an encoding is
and why it is needed.

You'll run into encoding problems anyway in your programmer's life. I don't
think it's a workaround, try this article:

http://www.joelonsoftware.com/articles/Unicode.html

I think it's highly useful, you could tell that to your students.
Please remember that most of the students will not become professional
programmers. Personally I think that encoding problems are nightmare in
general, and in Python in particular, and would like to avoid explaining
it as longer as possible. Besides, it won't be me, it will be a teacher
who will explain it, and the teacher themself might have a vague notion
about this topic.
Eclipse+Pydev seems to work with that. I'm not able to check with other
editors right now, but it seems you're experiencing a simple encoding
problem; your editor doesn't know which encoding you'd like to use, so it
defaults to ascii or iso-8859-1 leading to such problems.
No, my problem is that the emulation of sys.stdin/sys.stdout under
an IDE's interactive console doesn't work like the real
sys.stdin/sys.stdout under a real terminal.
Thanks,
Kirill.
Nov 19 '06 #7

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.
>
And another question: are you aware of the fact that recommended way to
handle non-ascii characters is to use unicode type? Most of IDEs should
work fine with unicode.

Usually using unicode type gives you much more headache than benefits
unless you are careful enough to never mix unicode and str objects.
For a professional programmer life is full of headaches like this :)
For high school students it could be troublesome and annoying, I agree.

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

As I see you have several options:
1. Set Russian locale and Russian language for non-unicode programs on
Windows.
2. Introduce students to unicode.
3. Wait for python 3.0
4. Hack some IDE to make unicode friendly environment like unicode
literals by default, type("Привет") == unicode, unicode
stdin/stdout, open() uses utf-8 encoding by default for text files,
etc...

-- Leo

Nov 19 '06 #8
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
Nov 20 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Mediocre Person | last post by:
Well, after years of teaching grade 12 students c++, I've decided to make a switch to Python. Why? * interactive mode for learning * less fussing with edit - compile - link - run - debug -...
176
by: Thomas Reichelt | last post by:
Moin, short question: is there any language combining the syntax, flexibility and great programming experience of Python with static typing? Is there a project to add static typing to Python? ...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
10
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
0
by: Kirill Simonov | last post by:
On Sat, Nov 18, 2006 at 10:08:22PM +0300, Oleg Broytmann wrote: Preferably. I believe that using a editor + command line will only make things worse because console and GUI have different...
17
by: Adam Olsen | last post by:
As was seen in another thread, there's a great deal of confusion with regard to surrogates. Most programmers assume Python's unicode type exposes only complete characters. Even CPython's own...
28
by: jmDesktop | last post by:
Studying OOP and noticed that Python does not have Interfaces. Is that correct? Is my schooling for nought on these OOP concepts if I use Python. Am I losing something if I don't use the...
0
by: yrogirg | last post by:
Actually, I need utf-8 to utf-8 encoding which would change the text to another keyboard layout (e.g. from english to russian ghbdtn -> ÐÒÉ×ÅÔ) and would not affect other symbols. I`m totally...
0
by: Wingware | last post by:
Hi, Wingware has released version 3.1.4 of Wing IDE. This bug fix release is available for all three product levels of Wing IDE. *Release Highlights* This release includes the following: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.