default setting of unicode set

Boudewijn Rempt boud at valdyas.org
Mon Jul 29 17:48:33 EDT 2002


Martin v. Löwis wrote:

> 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.

That sounds very fine -- but the problem is, it's so counter-intuitive,
that every newcomer will stumble over this. I just noticed another posting
on this topic... Having to use codects.open instead of the builtin is just
as bad. People will start using plain open, waste a few days trying to find
out why it doesn't work, and then perhaps discover the codecs module. 

-- 
Boudewijn Rempt | http://www.valdyas.org



More information about the Python-list mailing list