[Python-ideas] Fixing the Python 3 bytes constructor

Ethan Furman ethan at stoneleaf.us
Wed Apr 2 04:29:09 CEST 2014


On 04/01/2014 09:30 AM, Guido van Rossum wrote:
>>> On Sat, Mar 29, 2014 at 7:17 PM, Nick Coghlan wrote:
>>>>
>>>>  x = bytes.byte(data[0])
>
> Hm. I don't find that very attractive. You can't write Python 2/3 code using that idiom, and it's a lot longer than the
> original. The only redeeming feature is that it clearly fails when data is empty, and possibly that you don't have to
> compute the second index (which could be awkward if the first index is an expression).
>
> I'm not denying that we need bytes.byte(), but this doesn't sound like much of a motivation. Just pointing to the need
> of bytes/bytestring equivalents for chr() makes more sense to me.

We already have ord() and chr() -- maybe we should just add byte().

--
~Ethan~


More information about the Python-ideas mailing list