[Python-3000] What to do about "".join([b""])?

Jeffrey Yasskin jyasskin at gmail.com
Fri Nov 2 03:37:29 CET 2007


I'd naïvely vote for having "".join([non-strings]) raise a TypeError
unconditionally like it did in 2.5. I agree that it doesn't make sense
to special-case bytes here, but I don't know the reasons for changing
it to call str() in other cases.

On 11/1/07, Guido van Rossum <guido at python.org> wrote:
> Currently (in 3.0), "".join(<seq>) automatically applies str() to the
> items of <seq>, *except* if the item is a bytes instance -- then it
> raises a TypeError. Is that proper behavior? The alternative is to
> uniformly apply str(), which for bytes returns a string of the form
> "b'...'" or "buffer(b'...')" (depending on whether the bytes are
> immutable or not). Given that we killed the exception for "" == b""
> earlier, I'm tempted to remove the exception. Any opinions to the
> contrary?
>
> --
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/jyasskin%40gmail.com
>


-- 
Namasté,
Jeffrey Yasskin
http://jeffrey.yasskin.info/

"Religion is an improper response to the Divine." — "Skinny Legs and
All", by Tom Robbins


More information about the Python-3000 mailing list