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 -- http://mail.python.org/mailman/listinfo/python-list