[Python-3000] What to do about "".join([b""])?
Gregory P. Smith
greg at krypto.org
Fri Nov 2 05:21:32 CET 2007
-1 on having "".join() call str at all. yuck. shouldn't the caller just
"".join((str(x) for x in thing))
when they desire guaranteed stringification instead of a TypeError?
Anyways others disagree and this was already implemented so I assume my -1
is rejected, I at least agree on this:
+1 get rid of the inconsistent TypeError if a bytes or buffer object is in
the list. thats inconsistent. inserting the b'' or buffer(b'') syntax is
the consistent thing to do in that situation.
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
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> Python-3000 mailing list
> Python-3000 at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-3000