R. David Murray added the comment:
In case I wasn't clear: bytes-like object join's argument is *an iterable of
bytes-like objects*, not an iterable of ints.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24892
R. David Murray added the comment:
I said *enough* motivation. doing b'x'.join(b'anything') is a very uncommon
operation (as is the equivalent string case).
There is no parallel to the bytearray constructor, since that constructor does
not take an iterable of byte-like objects as its input,
Brett Cannon added the comment:
I agree with David. Concatenating ints to a bytes object doesn't work when you
directly work with ints and bytes, and so I don't think bytes.join should
special case it (Zen of Python: Special cases aren't special enough to break
the rules).
Thanks for the
R. David Murray added the comment:
I don't think there's enough motivation for making a special case here.
I think this should be rejected; it's working as designed, even if not everyone
agrees with the design.
--
nosy: +r.david.murray
___
Python
Timothy Geiser added the comment:
I believe the special case has already been made: iterating over bytes-like
objects returns ints. Natually, join() should take the same thing. Also,
constructor bytearray(iterable_of_ints), the mutable-sequence expression
ba[i:j:k] = t, and the function
New submission from Timothy Geiser:
You can't join bytes on another bytes object. (Everything below applies to
bytearray, as well)
x = b'foo'
y = b'barbaz'
x.join(y)
Traceback (most recent call last):
File pyshell#2, line 1, in module
x.join(y)
TypeError: sequence item 0: expected a