Marian Aldenhövel wrote: > Hi, > > I am very new to Python and have run into the following problem. If I do > something like > > dir = os.listdir(somepath) > for d in dir: > print d > > The program fails for filenames that contain non-ascii characters. > > 'ascii' codec can't encode characters in position 33-34: > > I have noticed that this seems to be a very common problem. I have read a lot > of postings regarding it but not really found a solution. Is there a simple > one?
No :) You're trying to deal with legacy terminals, you can't reliably print unicode characters across various terminals. It's not really Python's fault. > > What I specifically do not understand is why Python wants to interpret the > string as ASCII at all. Where is this setting hidden? http://www.python.org/moin/PrintFails Let me know if it's not clear. It would be great if other people fixed/improved this page. > I am running Python 2.3.4 on Windows XP and I want to run the program on > Debian sarge later. You need cross platform terminal that supports unicode output. Sergey. -- http://mail.python.org/mailman/listinfo/python-list