[Tutor] special characters is changed in filename output? Why?

Ole Jensen learning.python at dbmail.dk
Fri Aug 27 01:36:34 CEST 2004

Originally posted by ME on 24-Aug-2004:
> 2) If the user enters a special character (like above), the chacteres
> the outputted filename gets even more messed up (it looks like
> from the greek alphabet!).
> I do not know if there are any limitations to the os.rename() function
> concerning special characters, but if it is possible to create
> filenames/folders with special characters how do I do that?
> I guess that the flaw could also be from raw_input () as I do not
> that with the Unicode escape character (i.e. u"string").
> Any help with this wil be greatly appreciated.

This problem still challenges me. After some testing it now seems to me
that it's a flaw with python.exe! I noticed the problem only existed
when I double clicked my program icon bringing up the white text on
black background. And that it worked fine when running the program from
IDLE (F5).
>From a simple interactive walkthrough in the python command line (not

f  = open("æøå.txt", "w")

creates a file named: ‘›†.txt (I hope it show up correctly in this
If I did the exact same code in IDLE the file name would be correct i.e.

So I'm hoping one of you could help me with a workaround for this.
Presumably it is a known bug?
Or would I need to run the program through a shortcut that opens an IDLE
session that then runs my program!? And how would I do that? (I'm kinda
thinking out loud at this point :-) )

Ole Jensen

PS. also I just wanted to thank Kent for the criticism. I have already
used some of the suggestions you made and am going to look into the
os.path modules you mentioned.

More information about the Tutor mailing list