473,554 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3653
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\u04 38\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 "Unsupporte d 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.enco ding ==
'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 "Unsupporte d 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.enco ding ==
'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("u tf-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 "Unsupporte d 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.enco ding ==
'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("u tf-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
2329
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 - edit - compile - link - run -..... * lots of modules * I was getting tired of teaching c++! Bored teacher = bad instruction.
176
8037
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? Thank you, -- greetz tom
137
6988
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 pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain...
10
8026
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
0
298
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 encodings under Windows. So a student that have written a script in a GUI editor and saved it in UTF-8 would see garbage in console. Thanks, Kirill
17
4510
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 functions do this on occasion. This leads to different behaviour across platforms and makes it unnecessarily difficult to properly support all...
28
1653
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 "typical" oop constructs found in other languages (Java, C# come to mind.) I'm afraid that if I never use them I'll lose them and when I need them for...
0
2037
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 new to python and to more or less advanced programming. I couldn`t find the answer to the question anywhere. I`ve tried create simple utf to utf...
0
1268
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: * Debugger support for Python 2.6
0
7539
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7819
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8055
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7581
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5446
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1149
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
858
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.