Printing Filenames with non-Ascii-Characters

Marian Aldenhövel marian at mba-software.de
Wed Feb 2 04:19:52 EST 2005


Hi,

> Don't be tempted to ever change sys.defaultencoding in site.py, this is 
> site specific, meaning that if you ever distribute them, programs 
> relying on this setting may fail on other people's Python installations.

But wouldn't that be correct in my case?

 > If you're printing to the console, modern Pythons will try to guess the
 > console's encoding (e.g. cp850).

But it seems to have quessed wrong. I don't blame it, I would not know of
any way to reliably figure out this setting.

My console can print the filenames in question fine, I can verify that by
simple listing the directory, so it can display more than plain ascii.
The error message seems to indicate that ascii is used as target.

So if I were to fix this in sity.py to configure whatever encoding is
actually used on my system, I could print() my filenames without explicitly
calling encode()?

If the program then fails on other people's installations that would mean
one of two things:

1) They have not configured their encoding correctly.
2) The data to be printed cannot be encoded. This is unlikely as it comes
    from a local filename.

So wouldn't fixing site.py be the right thing to do? To enable Python to print
everything that can actually be printed and not barf at things it could print
but cannot because it defaults to plain ascii?

Ciao, MM
-- 
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013.
http://www.marian-aldenhoevel.de
"There is a procedure to follow in these cases, and if followed it can
  pretty well guarantee a generous measure of success, success here
  defined as survival with major extremities remaining attached."



More information about the Python-list mailing list