473,396 Members | 2,098 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,396 software developers and data experts.

IDLE and non-ascii encoding workaround?

Hello everyone,

there have already been a couple of threads about IDLE's sometimes
annoying disability to use special characters (in my case I would like
to use for example german umlauts like "ä" etc.).
I have made a workaround that *seems* to work, so I can at least store
files in the editor that use such characters ( on the python shell I
still get:

UnicodeError: ASCII encoding error: ordinal not in range(128)

but that does not matter much to me).
However I don't know very much about encoding issues, so maybe someone
can tell me if there might be problems that I don't see at the moment.
Here's what I did:

I changed one line in the writefile function in IOBinding.py into a
try-except statement. My function now looks like this:

def writefile(self, filename):
self.fixlastline()
#chars = str(self.text.get("1.0", "end-1c"))#original line
#workaround to fix the "umlaut" problem:
try:
chars = str(self.text.get("1.0", "end-1c"))
except:
c = self.text.get("1.0", "end-1c")
chars = ''
for i in c:
j = ord(i)
k = chr(j)
chars = chars + k
chars = str(chars)
#end of workaround
try:
f = open(filename, "w")
f.write(chars)
f.close()
## print "saved to", `filename`
return 1
except IOError, msg:
tkMessageBox.showerror("I/O Error", str(msg),
master=self.text)
return 0

This may take a few seconds if you want to save a large file, but at
least it is better as if it wasn't possible at all.

Any hints on this would be very appreciated.
Thanks in anticipation.

Michael
Jul 18 '05 #1
1 2550
kl*******@web.de (klappnase) writes:
Any hints on this would be very appreciated.


I recommend to use the IDLE that comes with Python 2.3.

Regards,
Martin
Jul 18 '05 #2

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

Similar topics

1
by: gjohannes | last post by:
Hi. I use Idle 1.1.1 on Python 2.4.1. The "Ctrl-" key bindings for indenting do not work on non-us keyboards where brackets are accessed by the "Alt Gr" key. The Tab key seem to work for...
19
by: Frank Rizzo | last post by:
I want to log the user out when there has been a period of inactivity in the application. The key here is inactivity of the application, not the system. I know that you can retrieve the...
5
by: Kevin Buchan | last post by:
How can I tell if the system is 'idle', or the screen saver is running, or the machine is locked? I am writing an application that could really benefit from knowing this information. During...
14
by: John Coleman | last post by:
Greetings, I am currently trying to learn Python through the excellent "Learning Python" book. I wrote my first non-trivial program, which began with several comment lines. One of the comment...
5
by: sam | last post by:
hi all, i continue to footle around on my spanking new ultra 20 (1.8GHz / Opteron Model 144), gradually trying to get to grips with python and unix both. the slow print time in IDLE had...
6
by: John (Z R) L | last post by:
Hi all, I am very new to programming, and I chose to study the Python language before C++. I am currently using the Wikibooks "Non-Programmer's Tutorial for Python", and am up to the section "Who...
0
by: Michael Boldin via alt email | last post by:
I installed python 2.5 and used the win package for installing MySQLdb. (Iam running Windows XP) Everything works as expected using python directly (Windows command shell) but using IDLE gives the...
3
by: Dominique | last post by:
Hello, Sorry bothering you with such a trivial problem. I installed python on a new mac at office. It seems everything is fine: in the console, I access to python. But I just can't start...
1
by: George2 | last post by:
Hello everyone, In your experience, what is system idle process doing? In my experience, this means system is (CPU is waiting for) doing some I/O, 1. like hard page fault; 2. waiting for...
0
by: Terry Reedy | last post by:
Murphy.MarkS@epamail.epa.gov wrote: I have both 2.5.2 and 3.0b2 loaded for all users on stock xp with all upgrades. I put /Python25 and /Python30 under Program Files instead of C:. As normal...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.