[Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer (original) (raw)

Walter Dörwald walter at livinglogic.de
Thu Sep 27 09:34:48 CEST 2007


Guido van Rossum wrote:

Please comment.

[...] Conversions between bytes or buffer objects and str objects must always be explicit, using an encoding. There are two equivalent APIs: str(b, <encoding>[, <errors>]) is equivalent to b.encode(<encoding>[, <errors>]), and bytes(s, <encoding>[, <errors>]) is equivalent to s.decode(<encoding>[, <errors>]).

This looks backwards to me. IMHO it should be:

str(b, <encoding>[, <errors>]) is equivalent to b.decode(<encoding>[, <errors>]), and bytes(s, <encoding>[, <errors>]) is equivalent to s.encode(<encoding>[, <errors>]).

Servus, Walter



More information about the Python-3000 mailing list