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

Guido van Rossum guido at python.org
Fri Nov 2 03:41:40 CET 2007


People wanted it for convenience. I agree it's debatable. OTOH "
".join([...]) could behave similarly to print(...) and there's
something to say for that. print(b"") will print b'' too once PEP 3137
is fully implemented.

On 11/1/07, Jeffrey Yasskin <jyasskin at gmail.com> wrote:
> 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
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list