[Python-Dev] Pre-PEP: The "bytes" object

Neil Schemenauer nas at arctrix.com
Sat Feb 25 02:14:37 CET 2006


Ron Adam <rrr at ronadam.com> wrote:
> Why was it decided that the unicode encoding argument should be ignored 
> if the first argument is a string?  Wouldn't an exception be better 
> rather than give the impression it does something when it doesn't?

>From the PEP:

    There is no sane meaning that the encoding can have in that
    case.  str objects *are* byte arrays and they know nothing about
    the encoding of character data they contain.  We need to assume
    that the programmer has provided str object that already uses
    the desired encoding.

Raising an exception would be a valid option.  However, passing the
string through unchanged makes the transition from str to bytes
easier.

  Neil



More information about the Python-Dev mailing list