print u"\u0432": why is this so hard? UnciodeEncodeError
Paul Prescod
paul at prescod.net
Sat Apr 10 19:11:11 EDT 2004
Nelson Minar wrote:
>...
>
> So when Python can't guess the encoding, it assumes that ASCII is the
> best it can do? Even as an American that annoys me; what do folks who
> need non-ASCII do in practice? Martin, what do you do when you write a
> Python script that prints your own name?
>
> I guess what I'd like is a way to set Python's default encoding and
> have that respected for files, terminals, etc. I'd also like some way
> to override the Unicode error mode. 'strict' is the right default, but
> I'd like the option to do 'ignore' or 'replace' globally.
The Python community has traditionally discouraged machine-specific
configuration. The more you depend on the machine configuration the more
likely you are to have problems when you move your program from one
computer to another.
The bug is in the third-party module that does not deal properly with
Unicode data!
>...
> Now that I know the trick I can do it. But part of the joy of Python
> is that it makes simple things simple. For a beginner to the language
> having to learn about the difference between sys.stdout and
> sys.__stdout__ seems a bit much.
Agreed: the module should handle it for you.
Paul Prescod
More information about the Python-list
mailing list