Rhodri James <rho...@kynesim.co.uk>: > On 17/07/18 02:17, Steven D'Aprano wrote: >> Ah yes, the unfortunate design error that iterating over byte-strings >> returns ints rather than single-byte strings. >> >> That decision seemed to make sense at the time it was made, but turned >> out to be an annoyance. It's a wart on Python 3, but fortunately one >> which is fairly easily dealt with by a helper function. > > I don't think I agree with you, but that may just be my heritage as a C > programmer. Every time I've iterated over a byte string, I've really > meant bytes (as in integers). Those bytes may correspond to ASCII > characters, but that's just a detail.
The practical issue is how you refer to ASCII bytes. What I've resorted to is: if nxt == b":"[0]: ... Alternatively, I *could* write: if nxt in b":": ... What's your favorite way of expressing character constants? Marko -- https://mail.python.org/mailman/listinfo/python-list