[Python-ideas] Fixing the Python 3 bytes constructor

Alexander Heger python at 2sn.net
Sat Mar 29 21:59:13 CET 2014


> I'm also +1 on Benjamin's idea of the iterate-as-bytes addition. That just
> leaves the inability to index into bytes and get back a single as the
> biggest annoyance in the bytes API.

The issue remains that there is no single byte type, but what is
returned is bytes type over which, again, you can iterate.  This is
different from a tuple of integers, when you iterate over that, you
get integers not length-one tuples of integers.  The issue, I think,
originates from the string concept where iteration also return a
string not a character - which python does not have.  A logical
extension would be to have to have character and byte types that are
returned when iterating of strings and bytes.  This is like taking a
giraffe out of a zoo and still calling the result a (small) zoo.  Or
calling a can of tuna a grocery store.


More information about the Python-ideas mailing list