[Python-3000] PEP 3108: Standard Library Reorganization

Giovanni Bajo rasky at develer.com
Sun Jan 7 05:07:37 CET 2007


Bill Janssen wrote:

> Will this work properly in Python 3K?  I tend to use base64, for
> example, to turn byte sequences into safe strings, so I need a way of
> doing "encode" on byte sequences, not just strings.
> 
> In general, base64.encode() should operate on byte sequences and
> return strings, and decode() should operate on strings and return byte
> sequences.

Yes. Not all encoders are unicode->str, and not all decoders are str->unicode. 
This is a point which is often forgotten. Having different functions for 
encoders ("foo".encode.base64()) like someone was proposing in this thread 
would also make it slightly less confusing.
-- 
Giovanni Bajo



More information about the Python-3000 mailing list