[Python-ideas] A possible transition plan to bytes-based iteration and indexing for binary data

Chris Angelico rosuav at gmail.com
Sun Jun 15 23:50:12 CEST 2014


On Mon, Jun 16, 2014 at 1:36 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> Hmmm. This is, I think, worrying. Now you have two sorts of ints:
>
> a = b'hello'[0]
> b = 104
> assert a == b  # succeeds
> assert bytes(a) == bytes(b)  # fails

ISTM the problem here is the bytes(104) constructor, which is of
marginal utility anyway. If that could be configured to produce a
warning, that would solve the problem, right? You might get that
assertion failing, but you'd get a warning that explains why.

ChrisA


More information about the Python-ideas mailing list