default setting of unicode set

Martin v. Löwis loewis at informatik.hu-berlin.de
Mon Jul 29 10:24:29 EDT 2002


Boudewijn Rempt <boud at valdyas.org> writes:

> This question comes up so often that I'm more and more convinced that
> the argument for deleting sys.setdefaultencoding() is flawed. Calling
> sys.setdefaultencoding("utf-8"), _is_ rather explicit, and beats having to 
> add .encode()'s to all string handling. 

The attempt to do so is flawed. It is not *all* string handling that
should use .encode, but just the output handling. In many cases, using
codecs.open instead of the builtin open will remove the need for many
explicit .encode calls.

Regards,
Martin



More information about the Python-list mailing list