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 8 3522
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
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
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
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
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
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.
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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 -...
|
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?
...
|
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...
|
by: Nikolay Petrov |
last post by:
How can I convert DOS cyrillic text to Unicode
|
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...
|
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...
|
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...
|
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...
|
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:
...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |