[issue24892] bytes.join() won't take it's own type as the argument

R. David Murray report at bugs.python.org
Wed Aug 19 14:35:41 CEST 2015


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, it takes an iterable of ints, as you point out.  There is no parallel to slice assignment, since a slice is by definition a bytes like object (that's why using the slice notation in the comprehension to the argument of join works).

The inconsistency is entirely a consequence of the fact that if you iterate a bytes-like object you get integers.  So, join's behavior is consistent with that, and as I said, *I* don't see enough motivation to make a special case exception here.  Others may disagree.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24892>
_______________________________________


More information about the Python-bugs-list mailing list