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

Jeff Shannon jeff at ccvcorp.com
Fri Aug 27 03:53:34 CEST 2004

Ole Jensen wrote:

> [code]
> f  = open("æøå.txt", "w")
> f.write("test")
> f.close()
> [/code]
> creates a file named: ‘›†.txt (I hope it show up correctly in this
> email)
> If I did the exact same code in IDLE the file name would be correct i.e.
> æøå.txt!

There seems to be a difference in how IDLE and the command-line Python 
interpreter handle locale -- this sort of thing seems to be a frequent 
problem.  The solution probably involves specifically setting locale 
somewhere in your Python-startup process.  Unfortunately, I don't know 
enough about this to offer any more specific guidance -- I'm one of 
those lazy Americans who has little cause to deal with non-ascii 
characters... ;)

Jeff Shannon
Credit International

More information about the Tutor mailing list